Eccube\Tests\Service\PluginServiceTest::testInstallPluginWithBrokenManagerAfterInstall PHP Method

testInstallPluginWithBrokenManagerAfterInstall() public method

インストーラが例外を上げた場合ロールバックできるか
    public function testInstallPluginWithBrokenManagerAfterInstall()
    {
        // インストールするプラグインを作成する
        $tmpname = "dummy" . sha1(mt_rand());
        $config = array();
        $config['name'] = $tmpname;
        $config['code'] = $tmpname;
        $config['version'] = $tmpname;
        $tmpdir = $this->createTempDir();
        $tmpfile = $tmpdir . '/plugin.tar';
        $tar = new \PharData($tmpfile);
        $tar->addFromString('config.yml', Yaml::dump($config));
        $dummyManager = <<<'EOD'
<?php
namespace Plugin\@@@@ ;

use Eccube\Plugin\AbstractPluginManager;
class PluginManager extends AbstractPluginManager
{
    public function install($plugin,$app)
    {
        echo "";
    }
    public function uninstall($config,$app)
    {
        throw new \Exception('hoge',1);
    }
    public function enable($config,$app)
    {
        throw new \Exception('hoge',1);
    }
    public function disable($config,$app)
    {
        throw new \Exception('hoge',1);
    }
    public function update($config,$app)
    {
        throw new \Exception('hoge',1);
    }

}

EOD;
        $dummyManager = str_replace('@@@@', $tmpname, $dummyManager);
        // イベントクラス名はランダムなのでヒアドキュメントの@@@@部分を置換
        $tar->addFromString("PluginManager.php", $dummyManager);
        $service = $this->app['eccube.service.plugin'];
        // 正しくインストールでき、enableのハンドラが呼ばれないことを確認
        $this->assertTrue($service->install($tmpfile));
        $this->assertTrue((bool) ($plugin = $this->app['eccube.repository.plugin']->findOneBy(array('name' => $tmpname))));
        $this->assertEquals(Constant::DISABLED, $plugin->getEnable());
        // インストール直後にプラグインがdisableになっているか
        try {
            $this->assertTrue($service->enable($plugin));
            // enableにしようとするが、例外発生
        } catch (\Exception $e) {
        }
        $this->app['orm.em']->detach($plugin);
        $this->assertTrue((bool) ($plugin = $this->app['eccube.repository.plugin']->findOneBy(array('name' => $tmpname))));
        $this->assertEquals(Constant::DISABLED, $plugin->getEnable());
        // プラグインがdisableのままになっていることを確認
    }