/** * Handles the "puli map --delete" command. * * @param Args $args The console arguments. * * @return int The status code. */ public function handleDelete(Args $args) { $repositoryPath = Path::makeAbsolute($args->getArgument('path'), $this->currentPath); if (!$this->repoManager->hasRootPathMapping($repositoryPath)) { throw new RuntimeException(sprintf('The path "%s" is not mapped in the package "%s".', $repositoryPath, $this->packages->getRootPackageName())); } $this->repoManager->removeRootPathMapping($repositoryPath); 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); }
private function initDefaultManager() { $conflictMappingRoot1 = new PathMapping('/conflict1', array('res', 'assets')); $conflictMappingPackage11 = new PathMapping('/conflict1', array('res', '@vendor/package2:res')); $conflictMappingPackage12 = new PathMapping('/conflict2', 'res'); $conflictMappingPackage21 = new PathMapping('/conflict1', 'res'); $conflictMappingPackage22 = new PathMapping('/conflict2', 'res'); $conflictMappingRoot1->load($this->packages->getRootPackage(), $this->packages); $conflictMappingPackage11->load($this->packages->get('vendor/package1'), $this->packages); $conflictMappingPackage12->load($this->packages->get('vendor/package1'), $this->packages); $conflictMappingPackage21->load($this->packages->get('vendor/package2'), $this->packages); $conflictMappingPackage22->load($this->packages->get('vendor/package2'), $this->packages); $conflict1 = new PathConflict('/conflict1'); $conflict1->addMappings(array($conflictMappingRoot1, $conflictMappingPackage11, $conflictMappingPackage21)); $conflict2 = new PathConflict('/conflict2/sub/path'); $conflict2->addMappings(array($conflictMappingPackage12, $conflictMappingPackage22)); $this->repoManager->expects($this->any())->method('findPathMappings')->willReturnCallback($this->returnFromMap(array(array($this->packageAndState('vendor/root', PathMappingState::ENABLED), array(new PathMapping('/root/enabled', array('res', 'assets')))), array($this->packageAndState('vendor/package1', PathMappingState::ENABLED), array(new PathMapping('/package1/enabled', array('res', '@vendor/package2:res')))), array($this->packageAndState('vendor/package2', PathMappingState::ENABLED), array(new PathMapping('/package2/enabled', 'res'))), array($this->packageAndState('vendor/root', PathMappingState::NOT_FOUND), array(new PathMapping('/root/not-found', 'res'))), array($this->packageAndState('vendor/package1', PathMappingState::NOT_FOUND), array(new PathMapping('/package1/not-found', 'res'))), array($this->packageAndState('vendor/package2', PathMappingState::NOT_FOUND), array(new PathMapping('/package2/not-found', 'res'))), array($this->packagesAndState(array('vendor/root'), PathMappingState::CONFLICT), array($conflictMappingRoot1)), array($this->packagesAndState(array('vendor/package1'), PathMappingState::CONFLICT), array($conflictMappingPackage11, $conflictMappingPackage12)), array($this->packagesAndState(array('vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingPackage21, $conflictMappingPackage22)), array($this->packagesAndState(array('vendor/root', 'vendor/package1'), PathMappingState::CONFLICT), array($conflictMappingRoot1, $conflictMappingPackage11, $conflictMappingPackage12)), array($this->packagesAndState(array('vendor/root', 'vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingRoot1, $conflictMappingPackage21, $conflictMappingPackage22)), array($this->packagesAndState(array('vendor/package1', 'vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingPackage11, $conflictMappingPackage12, $conflictMappingPackage21, $conflictMappingPackage22)), array($this->packagesAndState(array('vendor/root', 'vendor/package1', 'vendor/package2'), PathMappingState::CONFLICT), array($conflictMappingRoot1, $conflictMappingPackage11, $conflictMappingPackage12, $conflictMappingPackage21, $conflictMappingPackage22))))); }