private function initDefaultManager()
 {
     $this->packages->add(new RootPackage($this->rootPackageFile, $this->rootDir));
     $this->packages->add(new Package($this->packageFile1, $this->packageDir1));
     $this->packages->add(new Package($this->packageFile2, $this->packageDir2));
     $this->packages->add(new Package($this->packageFile3, $this->packageDir3));
     $this->manager = new RepositoryManagerImpl($this->environment, $this->repo, $this->packages, $this->packageFileStorage);
 }
 private function initDefaultManager()
 {
     $this->rootPackageFile->addInstallInfo($this->installInfo1);
     $this->rootPackageFile->addInstallInfo($this->installInfo2);
     $this->rootPackageFile->addInstallInfo($this->installInfo3);
     $this->packages->add(new RootPackage($this->rootPackageFile, $this->rootDir));
     $this->packages->add(new Package($this->packageFile1, $this->packageDir1, $this->installInfo1));
     $this->packages->add(new Package($this->packageFile2, $this->packageDir2, $this->installInfo2));
     $this->packages->add(new Package($this->packageFile3, $this->packageDir3, $this->installInfo3));
     $this->manager = new DiscoveryManagerImpl($this->environment, $this->discovery, $this->packages, $this->packageFileStorage, $this->logger);
 }
 public function testToArray()
 {
     $packageFile1 = new PackageFile('vendor/package1');
     $package1 = new Package($packageFile1, '/path1');
     $packageFile2 = new PackageFile('vendor/package2');
     $package2 = new Package($packageFile2, '/path2');
     $rootPackageFile = new RootPackageFile('vendor/root');
     $rootPackage = new RootPackage($rootPackageFile, '/path3');
     $this->collection->add($package1);
     $this->collection->add($rootPackage);
     $this->collection->add($package2);
     $this->assertSame(array('vendor/package1' => $package1, 'vendor/root' => $rootPackage, 'vendor/package2' => $package2), $this->collection->toArray());
 }
 private function renameNonRootPackage(Package $package, $newName)
 {
     $previousInstallInfo = $package->getInstallInfo();
     $installInfo = new InstallInfo($newName, $previousInstallInfo->getInstallPath());
     $installInfo->setInstallerName($previousInstallInfo->getInstallerName());
     foreach ($previousInstallInfo->getDisabledBindingUuids() as $uuid) {
         $installInfo->addDisabledBindingUuid($uuid);
     }
     $this->rootPackageFile->removeInstallInfo($package->getName());
     $this->rootPackageFile->addInstallInfo($installInfo);
     try {
         $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
     } catch (Exception $e) {
         $this->rootPackageFile->removeInstallInfo($newName);
         $this->rootPackageFile->addInstallInfo($previousInstallInfo);
         throw $e;
     }
     $this->packages->remove($package->getName());
     $this->packages->add(new Package($package->getPackageFile(), $package->getInstallPath(), $installInfo, $package->getLoadErrors()));
 }
Beispiel #5
0
 /**
  * Returns all packages with conflicting path mappings.
  *
  * The method {@link load()} needs to be called before calling this method,
  * otherwise an exception is thrown.
  *
  * @return PackageCollection The conflicting packages.
  *
  * @throws NotLoadedException If the mapping is not loaded.
  */
 public function getConflictingPackages()
 {
     if (null === $this->state) {
         throw new NotLoadedException('The mapping is not loaded.');
     }
     $collection = new PackageCollection();
     foreach ($this->conflicts as $conflict) {
         foreach ($conflict->getMappings() as $mapping) {
             if ($this === $mapping) {
                 continue;
             }
             $collection->add($mapping->getContainingPackage());
         }
     }
     return $collection;
 }