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

testInstallPluginWithConst() public method

const定義を含むpluginのインストール
    public function testInstallPluginWithConst()
    {
        // インストールするプラグインを作成する
        $tmpname = "dummy" . sha1(mt_rand());
        $config = array();
        $config['name'] = $tmpname . "_name";
        $config['code'] = $tmpname;
        $config['version'] = $tmpname . "_version";
        $config['const']['A'] = 'A';
        $config['const']['C'] = 1;
        $tmpdir = $this->createTempDir();
        $tmpfile = $tmpdir . '/plugin.tar';
        $tar = new \PharData($tmpfile);
        $tar->addFromString('config.yml', Yaml::dump($config));
        $service = $this->app['eccube.service.plugin'];
        // インストールできるか
        $this->assertTrue($service->install($tmpfile));
        $this->assertTrue((bool) ($plugin = $this->app['eccube.repository.plugin']->findOneBy(array('code' => $tmpname))));
        // インストール後disable状態でもconstがロードされているか
        $config = $this->app['config'];
        $config[$tmpname]['const']['A'] = null;
        $config[$tmpname]['const']['C'] = null;
        // const が存在しないのを確認後, 再ロード
        $this->assertFalse(isset($this->app['config'][$tmpname]['const']['A']));
        $this->assertFalse(isset($this->app['config'][$tmpname]['const']['C']));
        $this->app->initPluginEventDispatcher();
        $this->app->loadPlugin();
        $this->app->boot();
        $this->assertEquals('A', $this->app['config'][$tmpname]['const']['A']);
        $this->assertEquals('1', $this->app['config'][$tmpname]['const']['C']);
        // アンインストールできるか
        $this->assertTrue($service->uninstall($plugin));
    }