From 4cf5eef4612456700a85478f377f861a474b516d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 21 Oct 2024 09:44:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?InstallationsService::executeDefaultUpdates?= =?UTF-8?q?=E3=81=AE=E3=80=80=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Service/InstallationsService.php | 1 + .../Service/InstallationsServiceTest.php | 53 +------------------ 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/plugins/bc-installer/src/Service/InstallationsService.php b/plugins/bc-installer/src/Service/InstallationsService.php index d7e076edc2..f1c57c684f 100644 --- a/plugins/bc-installer/src/Service/InstallationsService.php +++ b/plugins/bc-installer/src/Service/InstallationsService.php @@ -337,6 +337,7 @@ public function setSiteName(string $name) * @return bool * @checked * @noTodo + * @unitTest */ public function executeDefaultUpdates(): bool { diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index 6ea99e31fd..aa7b7a3698 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -18,7 +18,6 @@ use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; use BaserCore\Utility\BcFile; -use BaserCore\Utility\BcFolder; use BcInstaller\Service\InstallationsService; use BcInstaller\Service\InstallationsServiceInterface; use Cake\Core\Configure; @@ -238,57 +237,7 @@ public function test_deployAdminAssets() */ public function testExecuteDefaultUpdates() { - $this->markTestIncomplete('このテストは未実装です。BcManagerComponentから移植中です。'); - $dbConfig = [ - 'datasource' => 'Database/BcMysql', - 'persistent' => false, - 'host' => 'localhost', - 'port' => '8889', - 'login' => 'root', - 'password' => 'root', - 'database' => 'basercms', - 'schema' => '', - 'prefix' => 'mysite_', - 'encoding' => 'utf8', - ]; - - // プラグイン有効化チェック用準備(ダミーのプラグインディレクトリを作成) - $testPluginPath = BASER_PLUGINS . 'Test' . DS; - $testPluginConfigPath = $testPluginPath . 'config.php'; - $Folder = new BcFolder($testPluginPath); - $Folder->create(); - $File = new BcFile($testPluginConfigPath); - $File->write('BcManager->executeDefaultUpdates($dbConfig); - - - // ===================== - // プラグイン有効化チェック - // ===================== - $File->delete(); - $Folder->delete($testPluginPath); - - $this->Plugin = ClassRegistry::init('Plugin'); - $plugin = $this->Plugin->find('first', [ - 'conditions' => ['id' => 4], - 'fields' => ['title', 'status'], - ] - ); - $expected = [ - 'Plugin' => [ - 'title' => 'テスト', - 'status' => 1, - ] - ]; - $this->Plugin->delete(4); - unset($this->Plugin); - $this->assertEquals($expected, $plugin, 'プラグインのステータスを正しく更新できません'); - $this->assertTrue($result, 'データベースのデータに初期更新に失敗しました'); + $this->assertTrue($this->Installations->executeDefaultUpdates()); } /** From ea7979cabc9b96231d74d60ce64dcc4b6769fc74 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Tue, 29 Oct 2024 10:20:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/TestCase/Service/InstallationsServiceTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index aa7b7a3698..63734a69cb 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -20,6 +20,7 @@ use BaserCore\Utility\BcFile; use BcInstaller\Service\InstallationsService; use BcInstaller\Service\InstallationsServiceInterface; +use BcSearchIndex\Test\Scenario\Service\SearchIndexesServiceScenario; use Cake\Core\Configure; use Cake\ORM\Exception\PersistenceFailedException; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -237,7 +238,15 @@ public function test_deployAdminAssets() */ public function testExecuteDefaultUpdates() { + //準備 + $this->loadFixtureScenario(SearchIndexesServiceScenario::class); + $searchIndexesTable = $this->getTableLocator()->get('SearchIndexes'); + //テスト前、search_indexes テーブルにデータを確認 + $this->assertEquals(1, $searchIndexesTable->find()->count()); + //テストを実行 $this->assertTrue($this->Installations->executeDefaultUpdates()); + //テスト後、search_indexes テーブルにデータを確認 + $this->assertEquals(3, $searchIndexesTable->find()->count()); } /**