/** * @expectedException \RuntimeException * @expectedExceptionMessage The type "my/type" does not exist in the package "vendor/root". */ public function testDeleteTypeFailsIfNotFound() { $args = self::$deleteCommand->parseArgs(new StringArgs('my/type')); $this->discoveryManager->expects($this->once())->method('hasRootBindingType')->with('my/type')->willReturn(false); $this->discoveryManager->expects($this->never())->method('removeRootBindingType'); $this->assertSame(0, $this->handler->handleRemove($args)); }
/** * Handles the "puli type --delete" command. * * @param Args $args The console arguments. * * @return int The status code. */ public function handleDelete(Args $args) { $typeName = $args->getArgument('name'); if (!$this->discoveryManager->hasRootTypeDescriptor($typeName)) { throw new RuntimeException(sprintf('The type "%s" does not exist in the package "%s".', $typeName, $this->packages->getRootPackageName())); } $this->discoveryManager->removeRootTypeDescriptor($typeName); return 0; }
/** * Handles the "build" command. * * @param Args $args The console arguments. * * @return int The status code. */ public function handle(Args $args) { $target = $args->getArgument('target'); if (!in_array($target, self::$targets)) { throw new RuntimeException(sprintf('Invalid build target "%s". Expected one of: "%s"', $target, implode('", "', self::$targets))); } if ('all' === $target || 'factory' === $target) { $this->factoryManager->autoGenerateFactoryClass(); } if ('all' === $target || 'repository' === $target) { $this->repoManager->clearRepository(); $this->repoManager->buildRepository(); } if ('all' === $target || 'discovery' === $target) { $this->discoveryManager->clearDiscovery(); $this->discoveryManager->buildDiscovery(); } return 0; }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Invalid build target "foobar". Expected one of: "all", "factory", "repository", "discovery" */ public function testBuildFailsIfInvalidTarget() { $args = self::$buildCommand->parseArgs(new StringArgs('foobar')); $this->factoryManager->expects($this->never())->method('autoGenerateFactoryClass'); $this->repoManager->expects($this->never())->method('clearRepository'); $this->repoManager->expects($this->never())->method('buildRepository'); $this->discoveryManager->expects($this->never())->method('clearDiscovery'); $this->discoveryManager->expects($this->never())->method('buildDiscovery'); $this->handler->handle($args); }
/** * @param string $uuidPrefix * * @return BindingDescriptor */ private function getBindingByUuidPrefix($uuidPrefix) { $expr = Expr::method('getUuid', Expr::startsWith($uuidPrefix)); $descriptors = $this->discoveryManager->findBindingDescriptors($expr); if (0 === count($descriptors)) { throw new RuntimeException(sprintf('The binding "%s" does not exist.', $uuidPrefix)); } if (count($descriptors) > 1) { throw new RuntimeException(sprintf('More than one binding matches the UUID prefix "%s".', $uuidPrefix)); } return reset($descriptors); }
public function testHasRootAssetMappingsWithExpression() { $this->discoveryManager->expects($this->once())->method('hasRootBindings')->with($this->webPath('/path'))->willReturn(true); $expr = Expr::same('/path', AssetMapping::SERVER_PATH); $this->assertTrue($this->manager->hasRootAssetMappings($expr)); }
/** * {@inheritdoc} */ public function hasAssetMappings(Expression $expr = null) { return $this->discoveryManager->hasBindingDescriptors($this->exprBuilder->buildExpression($expr)); }
private function initDefaultBindings() { $this->discoveryManager->expects($this->any())->method('findBindings')->willReturnCallback($this->returnFromMap(array(array($this->packageAndState('vendor/root', BindingState::ENABLED), array(new BindingDescriptor('/root/enabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID1)), new BindingDescriptor('/overridden', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID2)))), array($this->packageAndState('vendor/root', BindingState::DISABLED), array(new BindingDescriptor('/root/disabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID3)))), array($this->packageAndState('vendor/root', BindingState::UNDECIDED), array(new BindingDescriptor('/root/undecided', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID4)))), array($this->packageAndState('vendor/root', BindingState::TYPE_NOT_FOUND), array(new BindingDescriptor('/root/type-not-found', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID5)))), array($this->packageAndState('vendor/root', BindingState::TYPE_NOT_ENABLED), array(new BindingDescriptor('/root/type-not-enabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID17)))), array($this->packageAndState('vendor/root', BindingState::INVALID), array(new BindingDescriptor('/root/invalid', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID6)))), array($this->packageAndState('vendor/package1', BindingState::ENABLED), array(new BindingDescriptor('/package1/enabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID7)))), array($this->packageAndState('vendor/package1', BindingState::DISABLED), array(new BindingDescriptor('/package1/disabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID8)))), array($this->packageAndState('vendor/package1', BindingState::UNDECIDED), array(new BindingDescriptor('/package1/undecided', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID9)))), array($this->packageAndState('vendor/package1', BindingState::TYPE_NOT_FOUND), array(new BindingDescriptor('/package1/type-not-found', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID10)))), array($this->packageAndState('vendor/package1', BindingState::TYPE_NOT_ENABLED), array(new BindingDescriptor('/package1/type-not-enable', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID18)))), array($this->packageAndState('vendor/package1', BindingState::INVALID), array(new BindingDescriptor('/package1/invalid', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID11)))), array($this->packageAndState('vendor/package2', BindingState::ENABLED), array(new BindingDescriptor('/package2/enabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID12)))), array($this->packageAndState('vendor/package2', BindingState::DISABLED), array(new BindingDescriptor('/package2/disabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID13)))), array($this->packageAndState('vendor/package2', BindingState::UNDECIDED), array(new BindingDescriptor('/package2/undecided', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID14)))), array($this->packageAndState('vendor/package2', BindingState::TYPE_NOT_FOUND), array(new BindingDescriptor('/package2/type-not-found', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID15)))), array($this->packageAndState('vendor/package2', BindingState::TYPE_NOT_ENABLED), array(new BindingDescriptor('/package2/type-not-enabled', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID19)))), array($this->packageAndState('vendor/package2', BindingState::INVALID), array(new BindingDescriptor('/package2/invalid', 'my/type', array(), 'glob', Uuid::fromString(self::BINDING_UUID16))))))); }