1
0
Fork 0

PoolBuilderTest: Allow setting filter options for repositories

pull/8850/head
Nils Adermann 2020-08-28 13:07:11 +02:00
parent fcb9ef4899
commit c9201b8e40
2 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,36 @@
--TEST--
Fixed packages do not get loaded from the repos
--REQUEST--
{
"require": {
"some/pkg": "*",
"root/req": "*"
}
}
--FIXED--
[
{"name": "some/pkg", "version": "1.0.3", "id": 1},
{"name": "dep/dep", "version": "2.1.5", "id": 2}
]
--PACKAGE-REPOS--
[
[
{"name": "some/pkg", "version": "1.0.0"},
{"name": "some/pkg", "version": "1.1.0"},
{"name": "root/req", "version": "1.0.0", "require": {"dep/dep": "2.*"}},
{"name": "root/req", "version": "2.0.0", "require": {"dep/dep": "3.*"}},
{"name": "dep/dep", "version": "2.3.4"},
{"name": "dep/dep", "version": "3.0.1"}
]
]
--EXPECT--
[
1,
2,
"root/req-1.0.0.0",
"root/req-2.0.0.0"
]

View File

@ -14,6 +14,7 @@ namespace Composer\Test\DependencyResolver;
use Composer\IO\NullIO;
use Composer\Repository\ArrayRepository;
use Composer\Repository\FilterRepository;
use Composer\Repository\LockArrayRepository;
use Composer\DependencyResolver\DefaultPolicy;
use Composer\DependencyResolver\Pool;
@ -74,8 +75,16 @@ class PoolBuilderTest extends TestCase
$repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $rootReferences);
foreach ($packageRepos as $packages) {
$repositorySet->addRepository($repo = new ArrayRepository());
foreach ($packages as $package) {
$repo = new ArrayRepository();
if (isset($packages['canonical']) || isset($packages['only']) || isset($packages['exclude'])) {
$options = $packages;
$packages = $options['packages'];
unset($options['packages']);
$repositorySet->addRepository(new FilterRepository($repo, $options));
} else {
$repositorySet->addRepository($repo);
}
foreach ($packages as $package) {
$repo->addPackage($loadPackage($package));
}
}