1
0
Fork 0

Make sure aliased packages are removed correctly from the repository, fixes #7167

pull/7088/merge
Jordi Boggiano 2018-04-12 09:51:01 +02:00
parent 8d06832077
commit 036fc44c25
2 changed files with 12 additions and 1 deletions

View File

@ -167,6 +167,13 @@ class ArrayRepository extends BaseRepository
{
$packageId = $package->getUniqueName();
if ($package instanceof AliasPackage) {
$aliasedPackage = $package->getAliasOf();
if ($this === $aliasedPackage->getRepository()) {
$this->removePackage($aliasedPackage);
}
}
foreach ($this->getPackages() as $key => $repoPackage) {
if ($packageId === $repoPackage->getUniqueName()) {
array_splice($this->packages, $key, 1);

View File

@ -68,7 +68,7 @@ class ArrayRepositoryTest extends TestCase
$this->assertEquals('bar', $bar[0]->getName());
}
public function testAutomaticallyAddAliasedPackage()
public function testAutomaticallyAddAndRemoveAliasedPackage()
{
$repo = new ArrayRepository();
@ -80,6 +80,10 @@ class ArrayRepositoryTest extends TestCase
$this->assertCount(2, $repo);
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '1')));
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '2')));
$repo->removePackage($alias);
$this->assertCount(0, $repo);
}
public function testSearch()