/**
  * {@inheritdoc}
  */
 public function execute()
 {
     $rootPackageName = $this->rootPackage->getName();
     $rootPackageFile = $this->rootPackage->getPackageFile();
     foreach ($this->mapping->getConflictingPackages() as $conflictingPackage) {
         $packageName = $conflictingPackage->getName();
         if (!$rootPackageFile->hasOverriddenPackage($packageName)) {
             $rootPackageFile->addOverriddenPackage($packageName);
             $this->overriddenPackages[] = $packageName;
         }
         if (!$this->overrideGraph->hasEdge($packageName, $rootPackageName)) {
             $this->overrideGraph->addEdge($packageName, $rootPackageName);
             $this->addedEdgesFrom[] = $packageName;
         }
     }
 }
示例#2
0
 public function testGetConflictingPackages()
 {
     $mapping1 = new PathMapping('/path', 'resources');
     $mapping1->load($this->package1, $this->packages);
     $this->assertInstanceOf('Puli\\Manager\\Api\\Package\\PackageCollection', $mapping1->getConflictingPackages());
     $this->assertCount(0, $mapping1->getConflictingPackages());
     $mapping2 = new PathMapping('/path', 'resources');
     $mapping2->load($this->package2, $this->packages);
     $conflict = new PathConflict('/path/conflict');
     $mapping1->addConflict($conflict);
     $mapping2->addConflict($conflict);
     $this->assertCount(1, $mapping1->getConflictingPackages());
     $this->assertTrue($mapping1->getConflictingPackages()->contains('vendor/package2'));
     $this->assertCount(1, $mapping2->getConflictingPackages());
     $this->assertTrue($mapping2->getConflictingPackages()->contains('vendor/package1'));
     $mapping3 = new PathMapping('/path', 'resources');
     $mapping3->load($this->package3, $this->packages);
     $mapping3->addConflict($conflict);
     $this->assertCount(2, $mapping1->getConflictingPackages());
     $this->assertTrue($mapping1->getConflictingPackages()->contains('vendor/package2'));
     $this->assertTrue($mapping1->getConflictingPackages()->contains('vendor/package3'));
     $this->assertCount(2, $mapping2->getConflictingPackages());
     $this->assertTrue($mapping2->getConflictingPackages()->contains('vendor/package1'));
     $this->assertTrue($mapping2->getConflictingPackages()->contains('vendor/package3'));
     $this->assertCount(2, $mapping3->getConflictingPackages());
     $this->assertTrue($mapping3->getConflictingPackages()->contains('vendor/package1'));
     $this->assertTrue($mapping3->getConflictingPackages()->contains('vendor/package2'));
 }