コード例 #1
0
ファイル: PathMapping.php プロジェクト: sensorario/manager
 /**
  * Removes a conflict from the mapping.
  *
  * The method {@link load()} needs to be called before calling this method,
  * otherwise an exception is thrown.
  *
  * @param PathConflict $conflict The conflict to remove.
  *
  * @throws NotLoadedException If the mapping is not loaded.
  */
 public function removeConflict(PathConflict $conflict)
 {
     if (null === $this->state) {
         throw new NotLoadedException('The mapping is not loaded.');
     }
     $repositoryPath = $conflict->getRepositoryPath();
     if (!isset($this->conflicts[$repositoryPath]) || $conflict !== $this->conflicts[$repositoryPath]) {
         return;
     }
     unset($this->conflicts[$repositoryPath]);
     $conflict->removeMapping($this);
     $this->refreshState();
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function rollback()
 {
     foreach ($this->addedConflicts as $repositoryPath) {
         if ($this->conflicts->has($repositoryPath)) {
             $conflict = $this->conflicts->get($repositoryPath);
             $conflict->resolve();
             $this->conflicts->remove($repositoryPath);
         }
     }
     foreach ($this->removedConflicts as $repositoryPath => $conflictingMappings) {
         $conflict = new PathConflict($repositoryPath);
         $conflict->addMappings($conflictingMappings);
         $this->conflicts->add($conflict);
     }
 }
コード例 #3
0
ファイル: MapCommandHandlerTest.php プロジェクト: rejinka/cli
 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)))));
 }
コード例 #4
0
 public function testResolveRemovesAllMappings()
 {
     $mapping1 = new PathMapping('/path', 'resources');
     $mapping1->load($this->package1, $this->packages);
     $mapping2 = new PathMapping('/path', 'resources');
     $mapping2->load($this->package2, $this->packages);
     $mapping3 = new PathMapping('/path', 'resources');
     $mapping3->load($this->package3, $this->packages);
     $conflict = new PathConflict('/path/conflict');
     $conflict->addMapping($mapping1);
     $conflict->addMapping($mapping2);
     $conflict->addMapping($mapping3);
     $conflict->resolve();
     $this->assertCount(0, $conflict->getMappings());
     $this->assertCount(0, $mapping1->getConflicts());
     $this->assertCount(0, $mapping2->getConflicts());
     $this->assertCount(0, $mapping3->getConflicts());
     $this->assertTrue($conflict->isResolved());
 }
コード例 #5
0
ファイル: PathMappingTest.php プロジェクト: kormik/manager
 public function testAddConflictIgnoresDuplicates()
 {
     $mapping = new PathMapping('/path', 'resources');
     $mapping->load($this->package1, $this->packages);
     $conflict = new PathConflict('/path/conflict');
     $this->assertCount(0, $mapping->getConflicts());
     $this->assertCount(0, $conflict->getMappings());
     $mapping->addConflict($conflict);
     $mapping->addConflict($conflict);
     $this->assertCount(1, $mapping->getConflicts());
     $this->assertContains($conflict, $mapping->getConflicts());
     $this->assertCount(1, $conflict->getMappings());
     $this->assertContains($mapping, $conflict->getMappings());
     $this->assertTrue($mapping->isConflicting());
 }
コード例 #6
0
 /**
  * Add a path conflict to the collection.
  *
  * @param PathConflict $conflict The path conflict
  */
 public function add(PathConflict $conflict)
 {
     $this->conflicts[$conflict->getRepositoryPath()] = $conflict;
 }