Ejemplo n.º 1
0
 public function testRemoveRoot()
 {
     $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->collection->remove('vendor/root');
     $this->assertFalse($this->collection->contains('vendor/root'));
     $this->assertTrue($this->collection->contains('vendor/package1'));
     $this->assertTrue($this->collection->contains('vendor/package2'));
     $this->assertNull($this->collection->getRootPackage());
 }
Ejemplo n.º 2
0
 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()));
 }