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

testConfigYmlFormat() public method

config.ymlのフォーマット確認
public testConfigYmlFormat ( )
    public function testConfigYmlFormat()
    {
        $service = $this->app['eccube.service.plugin'];
        $tmpname = 'dummy' . mt_rand();
        $tmpfile = sys_get_temp_dir() . '/dummy' . mt_rand();
        // 必須項目のチェック
        $config = array();
        #$config['name'] = $tmpname;
        $config['code'] = $tmpname;
        $config['version'] = $tmpname;
        try {
            file_put_contents($tmpfile, Yaml::dump($config));
            $service->checkPluginArchiveContent($tmpfile);
            $this->fail("testConfigYmlFormat dont throw exception.");
        } catch (\Eccube\Exception\PluginException $e) {
        }
        $config = array();
        $config['name'] = $tmpname;
        #$config['code'] = $tmpname;
        $config['version'] = $tmpname;
        try {
            file_put_contents($tmpfile, Yaml::dump($config));
            $service->checkPluginArchiveContent($tmpfile);
            $this->fail("testConfigYmlFormat dont throw exception.");
        } catch (\Eccube\Exception\PluginException $e) {
        }
        $config = array();
        $config['name'] = $tmpname;
        $config['code'] = $tmpname;
        #$config['version'] = $tmpname;
        try {
            file_put_contents($tmpfile, Yaml::dump($config));
            $service->checkPluginArchiveContent($tmpfile);
            $this->fail("testConfigYmlFormat dont throw exception.");
        } catch (\Eccube\Exception\PluginException $e) {
        }
        // 禁止文字のチェック
        $config['name'] = $tmpname . "@";
        $config['code'] = $tmpname;
        $config['version'] = $tmpname;
        try {
            file_put_contents($tmpfile, Yaml::dump($config));
            $service->checkPluginArchiveContent($tmpfile);
            $this->fail("testConfigYmlFormat dont throw exception.");
        } catch (\Eccube\Exception\PluginException $e) {
        }
        $config = array();
        $config['name'] = $tmpname;
        $config['code'] = $tmpname . "#";
        $config['version'] = $tmpname;
        try {
            file_put_contents($tmpfile, Yaml::dump($config));
            $service->checkPluginArchiveContent($tmpfile);
            $this->fail("testConfigYmlFormat dont throw exception.");
        } catch (\Eccube\Exception\PluginException $e) {
        }
        // 長さのチェック
        $config = array();
        $config['name'] = $tmpname;
        $config['code'] = $tmpname;
        $config['version'] = str_repeat('a', 256);
        try {
            file_put_contents($tmpfile, Yaml::dump($config));
            $service->checkPluginArchiveContent($tmpfile);
            $this->fail("testConfigYmlFormat dont throw exception.");
        } catch (\Eccube\Exception\PluginException $e) {
        }
        $config = array();
        $config['name'] = $tmpname;
        $config['code'] = $tmpname;
        $config['version'] = $tmpname;
        $config['event'] = "&" . $tmpname;
        try {
            file_put_contents($tmpfile, Yaml::dump($config));
            $service->checkPluginArchiveContent($tmpfile);
            $this->fail("testConfigYmlFormat dont throw exception.");
        } catch (\Eccube\Exception\PluginException $e) {
        }
    }