public function testGetInstalledPackagesDoesNotIncludeRoot() { $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/package2' => $package2), $this->collection->getInstalledPackages()); }
/** * {@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; } }