예제 #1
0
 public function testGetters()
 {
     $data = json_decode(file_get_contents(__DIR__ . '/../Fixtures/PluginDir/TestPlugin/manifest.json'), true);
     $manifest = new Manifest($data);
     $this->assertEquals('test-plugin', $manifest->getName());
     $this->assertEquals('A custom class connector', $manifest->getDescription());
     $this->assertEquals(['connector'], $manifest->getKeywords());
     $this->assertEquals([['name' => 'Author name', 'homepage' => 'http://example.com', 'email' => '*****@*****.**']], $manifest->getAuthors());
     $this->assertEquals('http://example.com/project/example', $manifest->getHomepage());
     $this->assertEquals('MIT', $manifest->getLicense());
     $this->assertEquals('0.1', $manifest->getVersion());
     $this->assertEquals('3.8', $manifest->getMinimumPhraseanetVersion());
     $this->assertEquals('3.10', $manifest->getMaximumPhraseanetVersion());
     $this->assertEquals(['views', 'twig-views'], $manifest->getTwigPaths());
     $this->assertEquals([['class' => 'Vendor\\CustomCommand']], $manifest->getCommands());
     $this->assertEquals([['class' => 'Vendor\\PluginService']], $manifest->getServices());
     $this->assertEquals(['property' => 'value'], $manifest->getExtra());
 }
예제 #2
0
 public function validatePlugin($directory)
 {
     $this->ensureComposer($directory);
     $this->ensureManifest($directory);
     $this->ensureDir($directory . DIRECTORY_SEPARATOR . 'public');
     $manifest = $directory . DIRECTORY_SEPARATOR . 'manifest.json';
     $data = @json_decode(@file_get_contents($manifest));
     if (JSON_ERROR_NONE !== json_last_error()) {
         throw new PluginValidationException(sprintf('Unable to parse file %s', $manifest));
     }
     try {
         $this->manifestValidator->validate($data);
     } catch (JsonValidationException $e) {
         throw new PluginValidationException('Manifest file is invalid', $e->getCode(), $e);
     }
     $manifest = new Manifest($this->objectToArray($data));
     foreach ($manifest->getTwigPaths() as $path) {
         $this->ensureDirIn($directory . DIRECTORY_SEPARATOR . $path, $directory);
     }
     return $manifest;
 }