public function testDisabledIfDisabled() { $type = new BindingTypeDescriptor('vendor/type'); $type->load($this->package); $this->package->getInstallInfo()->addDisabledBindingUuid($this->uuid); $binding = new BindingDescriptor('/path', 'vendor/type', array(), 'glob', $this->uuid); $binding->load($this->package, $type); $this->assertSame(BindingState::DISABLED, $binding->getState()); }
private function refreshState() { if (null === $this->typeDescriptor || !$this->typeDescriptor->isLoaded()) { $this->state = BindingState::TYPE_NOT_FOUND; } elseif (!$this->typeDescriptor->isEnabled()) { $this->state = BindingState::TYPE_NOT_ENABLED; } elseif (count($this->loadErrors) > 0) { $this->state = BindingState::INVALID; } elseif ($this->containingPackage instanceof RootPackage) { $this->state = BindingState::ENABLED; } elseif ($this->containingPackage->getInstallInfo()->hasDisabledBindingUuid($this->binding->getUuid())) { $this->state = BindingState::DISABLED; } else { $this->state = BindingState::ENABLED; } }
public function testMatch() { $type = new BindingTypeDescriptor('vendor/type', null, array(new BindingParameterDescriptor('param'))); $type->load($this->package); $uuid = Uuid::fromString('abcdb814-9dad-11d1-80b4-00c04fd430c8'); $this->package->getInstallInfo()->addEnabledBindingUuid($uuid); $binding = new BindingDescriptor('/path', 'vendor/type', array('param' => 'value'), 'glob', $uuid); $binding->load($this->package, $type); $this->assertFalse($binding->match(Expr::same('foobar', BindingDescriptor::CONTAINING_PACKAGE))); $this->assertTrue($binding->match(Expr::same($this->package->getName(), BindingDescriptor::CONTAINING_PACKAGE))); $this->assertFalse($binding->match(Expr::same(BindingState::DISABLED, BindingDescriptor::STATE))); $this->assertTrue($binding->match(Expr::same(BindingState::ENABLED, BindingDescriptor::STATE))); $this->assertFalse($binding->match(Expr::startsWith('abce', BindingDescriptor::UUID))); $this->assertTrue($binding->match(Expr::startsWith('abcd', BindingDescriptor::UUID))); $this->assertFalse($binding->match(Expr::same('/path/nested', BindingDescriptor::QUERY))); $this->assertTrue($binding->match(Expr::same('/path', BindingDescriptor::QUERY))); $this->assertFalse($binding->match(Expr::same('xpath', BindingDescriptor::LANGUAGE))); $this->assertTrue($binding->match(Expr::same('glob', BindingDescriptor::LANGUAGE))); $this->assertFalse($binding->match(Expr::same('vendor/other', BindingDescriptor::TYPE_NAME))); $this->assertTrue($binding->match(Expr::same('vendor/type', BindingDescriptor::TYPE_NAME))); $this->assertFalse($binding->match(Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key('param', Expr::same('foobar'))))); $this->assertTrue($binding->match(Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key('param', Expr::same('value'))))); }
private function renameNonRootPackage(Package $package, $newName) { $previousInstallInfo = $package->getInstallInfo(); $installInfo = new InstallInfo($newName, $previousInstallInfo->getInstallPath()); $installInfo->setInstallerName($previousInstallInfo->getInstallerName()); foreach ($previousInstallInfo->getEnabledBindingUuids() as $uuid) { $installInfo->addEnabledBindingUuid($uuid); } foreach ($previousInstallInfo->getDisabledBindingUuids() as $uuid) { $installInfo->addDisabledBindingUuid($uuid); } $this->rootPackageFile->removeInstallInfo($package->getName()); $this->rootPackageFile->addInstallInfo($installInfo); try { $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile); } catch (Exception $e) { $this->rootPackageFile->removeInstallInfo($newName); $this->rootPackageFile->addInstallInfo($previousInstallInfo); throw $e; } $this->packages->remove($package->getName()); $this->packages->add(new Package($package->getPackageFile(), $package->getInstallPath(), $installInfo, $package->getLoadErrors())); }