Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstallationsService::installPlugin() のユニットテスト #3928

Open
wants to merge 6 commits into
base: 5.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,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->assertMatchesRegularExpression("/(You are already using the latest available Composer version|Upgrading to version)/", $rs['out'][1]);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion plugins/bc-installer/src/Service/InstallationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,14 @@ 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) $plugin = Plugin::getCollection()->create($name);
return $plugin->install();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use BcInstaller\Service\InstallationsServiceInterface;
use BcSearchIndex\Test\Scenario\Service\SearchIndexesServiceScenario;
use Cake\Core\Configure;
use Cake\Core\Exception\MissingPluginException;
use Cake\ORM\Exception\PersistenceFailedException;
use Cake\TestSuite\EmailTrait;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
Expand Down Expand Up @@ -331,7 +332,13 @@ public function testInstallCorePlugin()
*/
public function testInstallPlugin()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
//プラグインがインストールしない場合、
$this->assertTrue($this->Installations->installPlugin('BcPluginSample'));

//存在しないプラグイン
$this->expectException(MissingPluginException::class);
$this->expectExceptionMessage('Plugin `BcPluginSampleTest` could not be found.');
$this->Installations->installPlugin('BcPluginSampleTest');
}

/**
Expand Down
Loading