Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function addPluginClass($pluginClass)
 {
     if ($this->rootPackageFile->hasPluginClass($pluginClass)) {
         // Already installed locally
         return;
     }
     $this->validatePluginClass($pluginClass);
     $previousClasses = $this->rootPackageFile->getPluginClasses();
     $this->rootPackageFile->addPluginClass($pluginClass);
     try {
         $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
     } catch (Exception $e) {
         $this->rootPackageFile->setPluginClasses($previousClasses);
         throw $e;
     }
 }
Ejemplo n.º 2
0
 public function testHasPluginClasses()
 {
     $this->assertFalse($this->packageFile->hasPluginClasses());
     $this->packageFile->addPluginClass(self::PLUGIN_CLASS);
     $this->assertTrue($this->packageFile->hasPluginClasses());
 }
Ejemplo n.º 3
0
 public function testWriteRootPackageFileSortsPlugins()
 {
     $packageFile = new RootPackageFile();
     $packageFile->addPluginClass(__NAMESPACE__ . '\\PluginC');
     $packageFile->addPluginClass(__NAMESPACE__ . '\\PluginA');
     $packageFile->addPluginClass(__NAMESPACE__ . '\\PluginB');
     $this->writer->writePackageFile($packageFile, $this->tempFile);
     $this->assertFileExists($this->tempFile);
     $this->assertJsonFileEquals(__DIR__ . '/Fixtures/json/sorted-plugins.json', $this->tempFile);
 }
Ejemplo n.º 4
0
    public function testSerializeRootPackageFileSortsPlugins()
    {
        $packageFile = new RootPackageFile();
        $packageFile->addPluginClass(__NAMESPACE__ . '\\PluginC');
        $packageFile->addPluginClass(__NAMESPACE__ . '\\PluginA');
        $packageFile->addPluginClass(__NAMESPACE__ . '\\PluginB');
        $json = <<<JSON
{
    "version": "1.0",
    "plugins": [
        "Puli\\\\Manager\\\\Tests\\\\Package\\\\PluginA",
        "Puli\\\\Manager\\\\Tests\\\\Package\\\\PluginB",
        "Puli\\\\Manager\\\\Tests\\\\Package\\\\PluginC"
    ]
}

JSON;
        $this->assertJsonEquals($json, $this->serializer->serializeRootPackageFile($packageFile));
    }