diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index cb8c3f075c..b2a828347d 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -302,6 +302,7 @@ public function initFiles(ServerRequest $request): void * @return \Cake\Datasource\ConnectionInterface * @checked * @noTodo + * @unitTest */ public function connectDb(ServerRequest $request): \Cake\Datasource\ConnectionInterface { diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 33c325f507..7389c3e2f4 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -533,7 +533,28 @@ public function test_initFiles() */ public function test_connectDb() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //準備 + $session = new Session(); + $request = new ServerRequest(['session' => $session]); + $session->write('Installation', [ + "datasource" => "MySQL", + "dbSchema" => "test_basercms", + 'dbType' => 'mysql', + 'dbName' => 'test_db', + 'dbHost' => 'bc-db', + 'dbPrefix' => '', + 'dbPort' => '3306', + 'dbEncoding' => 'utf-8', + 'dbDataPattern' => 'BcThemeSample.default', + "dbUsername" => "root", + "dbPassword" => "root", + ]); + //準備 + $rs = $this->Installations->connectDb($request); + + // 接続できていること + $this->assertNotEmpty($rs); + $this->assertTrue($rs->getDriver()->isConnected()); } /**