Make sure aliased packages are removed correctly from the repository, fixes #7167
parent
8d06832077
commit
036fc44c25
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue