public function testReplace() { $packageFile1 = new PackageFile('vendor/package1'); $package1 = new Package($packageFile1, '/path1'); $packageFile2 = new PackageFile('vendor/package2'); $package2 = new Package($packageFile2, '/path2'); $packageFile3 = new PackageFile('vendor/package3'); $package3 = new Package($packageFile3, '/path3'); $this->collection->add($package1); $this->collection->replace(array($package2, $package3)); $this->assertSame(array('vendor/package2' => $package2, 'vendor/package3' => $package3), $this->collection->toArray()); }
/** * {@inheritdoc} */ public function removePackages(Expression $expr) { $this->assertPackagesLoaded(); $installInfos = $this->rootPackageFile->getInstallInfos(); $packages = $this->packages->toArray(); foreach ($this->packages->getInstalledPackages() as $package) { if ($package->match($expr)) { $this->rootPackageFile->removeInstallInfo($package->getName()); $this->packages->remove($package->getName()); } } if (!$installInfos) { return; } try { $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile); } catch (Exception $e) { $this->rootPackageFile->setInstallInfos($installInfos); $this->packages->replace($packages); throw $e; } }