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 1 commit 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
5 changes: 4 additions & 1 deletion plugins/bc-installer/src/Service/InstallationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryuring こちらはBoolean形で返しましたのでここでreturnをしないと次の393行目にバグを発生します。
レビューをお願いします。

return true;
$plugin = Plugin::getCollection()->create($name);
return $plugin->install();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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');
}

/**
Expand Down
Loading