From c9a5f6ae03bbb1893e0762d269f5c60e0c99cf3d Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Fri, 25 Oct 2024 12:16:47 +0900 Subject: [PATCH] =?UTF-8?q?InstallationsAdminService::connectDb()=20?= =?UTF-8?q?=E3=81=AE=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/InstallationsAdminService.php | 1 + .../Admin/InstallationsAdminServiceTest.php | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index fc79636031..2fc27d1ba6 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -301,6 +301,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 71d743a13b..cb41975db9 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -489,7 +489,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()); } /**