diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index 59eb529497..e3608d05d4 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -138,6 +138,7 @@ public function getDefaultValuesStep4(ServerRequest $request): array * @return void * @checked * @noTodo + * @unitTest */ public function writeDbSettingToSession(ServerRequest $request, array $data): void { diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 14f7316413..a517371e4d 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -206,10 +206,103 @@ public static function getDefaultValuesStep4DataProvider() /** * test writeDbSettingToSession + * @param array $data + * @param array $expected + * @dataProvider writeDbSettingToSessionDataProvider */ - public function test_writeDbSettingToSession() + public function test_writeDbSettingToSession($data, $expected) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $session = new Session(); + $request = new ServerRequest(['session' => $session]); + + $this->Installations->writeDbSettingToSession($request, $data); + + $result = $session->read(); + $this->assertEquals($expected, $result); + } + + public static function writeDbSettingToSessionDataProvider() + { + return [ + [ + [ + 'dbType' => 'mysql', + 'dbHost' => 'localhost', + 'dbPort' => '3306', + 'dbUsername' => 'root', + 'dbPassword' => 'password', + 'dbPrefix' => 'bc_', + 'dbName' => 'test_database_mysql', + 'dbDataPattern' => 'BcSample.default', + ], + [ + 'Installation' => [ + 'dbType' => 'mysql', + 'dbHost' => 'localhost', + 'dbPort' => '3306', + 'dbUsername' => 'root', + 'dbPassword' => 'password', + 'dbPrefix' => 'bc_', + 'dbName' => 'test_database_mysql', + 'dbSchema' => '', + 'dbEncoding' => 'utf8mb4', + 'dbDataPattern' => 'BcSample.default', + ] + ] + ], + [ + [ + 'dbType' => 'postgres', + 'dbHost' => 'localhost', + 'dbPort' => '5432', + 'dbUsername' => 'root', + 'dbPassword' => 'password', + 'dbPrefix' => 'bc_', + 'dbName' => 'test_database', + 'dbDataPattern' => 'BcSample.default', + ], + [ + 'Installation' => [ + 'dbType' => 'postgres', + 'dbHost' => 'localhost', + 'dbPort' => '5432', + 'dbUsername' => 'root', + 'dbPassword' => 'password', + 'dbPrefix' => 'bc_', + 'dbName' => 'test_database', + 'dbSchema' => 'public', + 'dbEncoding' => 'utf8', + 'dbDataPattern' => 'BcSample.default' + ] + ] + ], + [ + [ + 'dbType' => 'sqlite', + 'dbHost' => '', + 'dbPort' => '', + 'dbUsername' => '', + 'dbPassword' => '', + 'dbPrefix' => '', + 'dbName' => 'test_database_sqlite', + 'dbDataPattern' => 'BcSample.default', + ], + [ + 'Installation' => [ + 'dbType' => 'sqlite', + 'dbHost' => '', + 'dbPort' => '', + 'dbUsername' => '', + 'dbPassword' => '', + 'dbPrefix' => '', + 'dbName' => 'test_database_sqlite', + 'dbSchema' => '', + 'dbEncoding' => 'utf8', + 'dbDataPattern' => 'BcSample.default', + ] + ] + ], + ]; } /**