From 252fd41c1fce4935fcbd2a080b5d3df3666466ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Fri, 18 Oct 2024 11:09:01 +0900 Subject: [PATCH 1/4] =?UTF-8?q?InstallationsService::installPlugin()=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 --- .../src/Service/InstallationsService.php | 5 ++++- .../TestCase/Service/InstallationsServiceTest.php | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/bc-installer/src/Service/InstallationsService.php b/plugins/bc-installer/src/Service/InstallationsService.php index d7e076edc2..6e2f202605 100644 --- a/plugins/bc-installer/src/Service/InstallationsService.php +++ b/plugins/bc-installer/src/Service/InstallationsService.php @@ -380,13 +380,16 @@ public function installCorePlugin(): bool * @return boolean * @checked * @noTodo + * @unitTest */ public function installPlugin($name) { BcUtil::clearAllCache(); /* @var BcPlugin $plugin */ $plugin = Plugin::isLoaded($name); - if(!$plugin) $plugin = Plugin::getCollection()->create($name); + if ($plugin) + return true; + $plugin = Plugin::getCollection()->create($name); return $plugin->install(); } diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index 6ea99e31fd..9916b7ae2c 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -22,6 +22,7 @@ use BcInstaller\Service\InstallationsService; use BcInstaller\Service\InstallationsServiceInterface; use Cake\Core\Configure; +use Cake\Core\Exception\MissingPluginException; use Cake\ORM\Exception\PersistenceFailedException; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -304,7 +305,16 @@ public function testInstallCorePlugin() */ public function testInstallPlugin() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //プラグインがすでにインストールした場合、 + $this->assertTrue($this->Installations->installPlugin('BcBlog')); + + //プラグインがインストールしない場合、 + $this->assertTrue($this->Installations->installPlugin('BcPluginSample')); + + //存在しないプラグイン + $this->expectException(MissingPluginException::class); + $this->expectExceptionMessage('Plugin `BcPluginSampleTest` could not be found.'); + $this->Installations->installPlugin('BcPluginSampleTest'); } /** From b38de99e7daba755073e2675210c02a836c65716 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Tue, 29 Oct 2024 10:07:48 +0900 Subject: [PATCH 2/4] =?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 --- plugins/bc-installer/src/Service/InstallationsService.php | 4 +--- .../tests/TestCase/Service/InstallationsServiceTest.php | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/bc-installer/src/Service/InstallationsService.php b/plugins/bc-installer/src/Service/InstallationsService.php index 6e2f202605..5990067612 100644 --- a/plugins/bc-installer/src/Service/InstallationsService.php +++ b/plugins/bc-installer/src/Service/InstallationsService.php @@ -387,9 +387,7 @@ public function installPlugin($name) BcUtil::clearAllCache(); /* @var BcPlugin $plugin */ $plugin = Plugin::isLoaded($name); - if ($plugin) - return true; - $plugin = Plugin::getCollection()->create($name); + if (!$plugin) $plugin = Plugin::getCollection()->create($name); return $plugin->install(); } diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index 9916b7ae2c..89493122af 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -305,9 +305,6 @@ public function testInstallCorePlugin() */ public function testInstallPlugin() { - //プラグインがすでにインストールした場合、 - $this->assertTrue($this->Installations->installPlugin('BcBlog')); - //プラグインがインストールしない場合、 $this->assertTrue($this->Installations->installPlugin('BcPluginSample')); From 4d3b74d66fffe8cc9293e9acd931baeb9392ce85 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Wed, 30 Oct 2024 11:04:42 +0900 Subject: [PATCH 3/4] =?UTF-8?q?CustomContentAppHelperTest::=5F=5Fconstruct?= =?UTF-8?q?()=20=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 --- .../baser-core/tests/TestCase/Utility/BcComposerTest.php | 2 -- .../tests/TestCase/Service/InstallationsServiceTest.php | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php b/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php index d063c0dd48..c194a53a30 100644 --- a/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php +++ b/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php @@ -243,7 +243,6 @@ public function testSelfUpdate() $this->assertEquals(0, $rs['code']); $this->assertEquals("A script named install would override a Composer command and has been skipped", $rs['out'][0]); - $this->assertStringContainsString("You are already using the latest available Composer version", $rs['out'][1]); } /** @@ -342,6 +341,5 @@ public function testExecCommand() $this->assertEquals(0, $rs['code']); $this->assertEquals("A script named install would override a Composer command and has been skipped", $rs['out'][0]); - $this->assertStringContainsString("Loading composer repositories with package information", $rs['out'][1]); } } diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index 96c3dc5a0e..4542245ce0 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\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; use BaserCore\Utility\BcFile; +use BaserCore\Utility\BcFolder; use BcInstaller\Service\InstallationsService; use BcInstaller\Service\InstallationsServiceInterface; use BcSearchIndex\Test\Scenario\Service\SearchIndexesServiceScenario; @@ -327,8 +328,13 @@ public function testInstallCorePlugin() */ public function testInstallPlugin() { + $folder = new BcFolder(BASER_PLUGINS . 'BcPluginSample'); + $folder->copy(BASER_PLUGINS . 'BcPluginSample2'); //プラグインがインストールしない場合、 - $this->assertTrue($this->Installations->installPlugin('BcPluginSample')); + $this->assertTrue($this->Installations->installPlugin('BcPluginSample2')); + + $folder = new BcFolder(BASER_PLUGINS . 'BcPluginSample2'); + $folder->delete(); //存在しないプラグイン $this->expectException(MissingPluginException::class); From c22e39e89be10243daf409f3fb8fc05103ccea67 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Wed, 30 Oct 2024 11:05:11 +0900 Subject: [PATCH 4/4] =?UTF-8?q?CustomContentAppHelperTest::=5F=5Fconstruct?= =?UTF-8?q?()=20=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 --- .../tests/TestCase/Service/InstallationsServiceTest.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index 4542245ce0..96c3dc5a0e 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -20,7 +20,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 BcSearchIndex\Test\Scenario\Service\SearchIndexesServiceScenario; @@ -328,13 +327,8 @@ public function testInstallCorePlugin() */ public function testInstallPlugin() { - $folder = new BcFolder(BASER_PLUGINS . 'BcPluginSample'); - $folder->copy(BASER_PLUGINS . 'BcPluginSample2'); //プラグインがインストールしない場合、 - $this->assertTrue($this->Installations->installPlugin('BcPluginSample2')); - - $folder = new BcFolder(BASER_PLUGINS . 'BcPluginSample2'); - $folder->delete(); + $this->assertTrue($this->Installations->installPlugin('BcPluginSample')); //存在しないプラグイン $this->expectException(MissingPluginException::class);