Ejemplo n.º 1
0
 public function testDisableBinding()
 {
     $args = self::$disableCommand->parseArgs(new StringArgs('ab12'));
     $descriptor = new BindingDescriptor('/path', 'my/type', array(), 'glob');
     $descriptor->load($this->packages->get('vendor/package1'));
     $this->discoveryManager->expects($this->once())->method('findBindings')->with($this->uuid('ab12'))->willReturn(array($descriptor));
     $this->discoveryManager->expects($this->once())->method('disableBinding')->with($descriptor->getUuid());
     $statusCode = $this->handler->handleDisable($args, $this->io);
     $this->assertSame(0, $statusCode);
     $this->assertEmpty($this->io->fetchOutput());
     $this->assertEmpty($this->io->fetchErrors());
 }
Ejemplo n.º 2
0
 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)))));
 }
Ejemplo n.º 3
0
 /**
  * @expectedException \Puli\Manager\Api\Package\NoSuchPackageException
  */
 public function testGetPackageFailsIfNotFound()
 {
     $this->collection->get('vendor/package');
 }
Ejemplo n.º 4
0
 private function makeAbsolute($relativePath, Package $containingPackage, PackageCollection $packages)
 {
     // Reference to install path of other package
     if ('@' !== $relativePath[0] || false === ($pos = strpos($relativePath, ':'))) {
         return $containingPackage->getInstallPath() . '/' . $relativePath;
     }
     $refPackageName = substr($relativePath, 1, $pos - 1);
     if (!$packages->contains($refPackageName)) {
         throw new NoSuchPackageException(sprintf('The package "%s" referenced in the resource path "%s" was not ' . 'found. Maybe the package is not installed?', $refPackageName, $relativePath));
     }
     $refPackage = $packages->get($refPackageName);
     return $refPackage->getInstallPath() . '/' . substr($relativePath, $pos + 1);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function getPackage($name)
 {
     Assert::string($name, 'The package name must be a string. Got: %s');
     $this->assertPackagesLoaded();
     return $this->packages->get($name);
 }