public function rollback() { if ($this->previousDescriptor) { $this->rootPackageFile->addTypeDescriptor($this->previousDescriptor); } else { $this->rootPackageFile->removeTypeDescriptor($this->typeDescriptor->getName()); } }
public function testWriteRootPackageFile() { $installInfo1 = new InstallInfo('vendor/package1', '/path/to/package1'); $installInfo1->setInstallerName('composer'); $installInfo1->addEnabledBindingUuid(Uuid::fromString('a54e5668-2b36-43f4-a32c-2d175092b77d')); $installInfo1->addDisabledBindingUuid(Uuid::fromString('4d02ee67-d845-4789-a9c1-8301351c6f5a')); $installInfo2 = new InstallInfo('vendor/package2', '/path/to/package2'); $baseConfig = new Config(); $packageFile = new RootPackageFile(null, null, $baseConfig); $packageFile->setPackageName('my/application'); $packageFile->addPathMapping(new PathMapping('/app', 'res')); $packageFile->addBindingDescriptor(new BindingDescriptor('/app/config*.yml', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID1))); $packageFile->addTypeDescriptor(new BindingTypeDescriptor('my/type', 'Description of my type.', array(new BindingParameterDescriptor('param', BindingParameterDescriptor::OPTIONAL, 1234, 'Description of the parameter.')))); $packageFile->setOverriddenPackages(array('acme/blog')); $packageFile->setOverrideOrder(array('acme/blog-extension1', 'acme/blog-extension2')); $packageFile->addPluginClass('Puli\\Manager\\Tests\\Api\\Package\\Fixtures\\TestPlugin'); $packageFile->getConfig()->merge(array(Config::PULI_DIR => 'puli-dir', Config::FACTORY_OUT_CLASS => 'Puli\\MyFactory', Config::FACTORY_OUT_FILE => '{$puli-dir}/MyFactory.php', Config::REPOSITORY_TYPE => 'my-type', Config::REPOSITORY_PATH => '{$puli-dir}/my-repo', Config::DISCOVERY_STORE_TYPE => 'my-store-type')); $packageFile->addInstallInfo($installInfo1); $packageFile->addInstallInfo($installInfo2); $packageFile->setExtraKeys(array('extra1' => 'value', 'extra2' => array('key' => 'value'))); $this->writer->writePackageFile($packageFile, $this->tempFile); $this->assertFileExists($this->tempFile); $this->assertJsonFileEquals(__DIR__ . '/Fixtures/json/full-root.json', $this->tempFile); }
/** * {@inheritdoc} */ public function rollback() { if ($this->previousDescriptor) { $this->rootPackageFile->addTypeDescriptor($this->previousDescriptor); } }