mirror of
https://github.com/composer/composer
synced 2025-05-10 17:12:51 +00:00
Fix priority of aliases when mixing root package aliases with branch-alias ones, fixes #576
This commit is contained in:
parent
870d745475
commit
06fb1b8083
4 changed files with 92 additions and 4 deletions
|
@ -18,6 +18,7 @@ use Composer\DependencyResolver\DefaultPolicy;
|
|||
use Composer\DependencyResolver\Pool;
|
||||
use Composer\DependencyResolver\Literal;
|
||||
use Composer\Package\Link;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||
use Composer\Test\TestCase;
|
||||
|
||||
|
@ -99,6 +100,35 @@ class DefaultPolicyTest extends TestCase
|
|||
$this->assertEquals($expected, $selected);
|
||||
}
|
||||
|
||||
public function testSelectLocalReposFirst()
|
||||
{
|
||||
$this->repoImportant = new ArrayRepository;
|
||||
|
||||
$this->repo->addPackage($packageA = $this->getPackage('A', 'dev-master'));
|
||||
$this->repo->addPackage($packageAAlias = new AliasPackage($packageA, '2.1.9999999.9999999-dev', '2.1.x-dev'));
|
||||
$this->repoImportant->addPackage($packageAImportant = $this->getPackage('A', 'dev-feature-a'));
|
||||
$this->repoImportant->addPackage($packageAAliasImportant = new AliasPackage($packageAImportant, '2.1.9999999.9999999-dev', '2.1.x-dev'));
|
||||
$this->repoImportant->addPackage($packageA2Important = $this->getPackage('A', 'dev-master'));
|
||||
$this->repoImportant->addPackage($packageA2AliasImportant = new AliasPackage($packageA2Important, '2.1.9999999.9999999-dev', '2.1.x-dev'));
|
||||
$packageAAliasImportant->setRootPackageAlias(true);
|
||||
|
||||
$this->pool->addRepository($this->repoInstalled);
|
||||
$this->pool->addRepository($this->repoImportant);
|
||||
$this->pool->addRepository($this->repo);
|
||||
|
||||
$packages = $this->pool->whatProvides('a', new VersionConstraint('=', '2.1.9999999.9999999-dev'));
|
||||
$literals = array();
|
||||
foreach ($packages as $package) {
|
||||
$literals[] = new Literal($package, true);
|
||||
}
|
||||
|
||||
$expected = array(new Literal($packageAAliasImportant, true));
|
||||
|
||||
$selected = $this->policy->selectPreferedPackages($this->pool, array(), $literals);
|
||||
|
||||
$this->assertEquals($expected, $selected);
|
||||
}
|
||||
|
||||
public function testSelectAllProviders()
|
||||
{
|
||||
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue