Add failing test and fix attempt
parent
4e5be9ee7d
commit
05d5db9475
|
@ -17,6 +17,7 @@ use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
|
||||||
use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
|
use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
|
||||||
use Composer\Package\BasePackage;
|
use Composer\Package\BasePackage;
|
||||||
use Composer\Package\AliasPackage;
|
use Composer\Package\AliasPackage;
|
||||||
|
use Composer\Package\RootPackageInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nils Adermann <naderman@naderman.de>
|
* @author Nils Adermann <naderman@naderman.de>
|
||||||
|
@ -203,6 +204,16 @@ class RuleSetGenerator
|
||||||
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
|
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
|
||||||
|
|
||||||
foreach ($possibleRequires as $require) {
|
foreach ($possibleRequires as $require) {
|
||||||
|
$requirers = [];
|
||||||
|
foreach ($this->pool->getPackages() as $pkg) {
|
||||||
|
if (isset($pkg->getRequires()[$require->getName()])) {
|
||||||
|
$requirers[] = $pkg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($requirers) {
|
||||||
|
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $requirers, Rule::RULE_PACKAGE_REQUIRES, null));
|
||||||
|
}
|
||||||
|
|
||||||
$workQueue->enqueue($require);
|
$workQueue->enqueue($require);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,6 +290,16 @@ class RuleSetGenerator
|
||||||
if ($packages) {
|
if ($packages) {
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
$this->addRulesForPackage($package, $platformRequirementFilter);
|
$this->addRulesForPackage($package, $platformRequirementFilter);
|
||||||
|
|
||||||
|
$requirers = [];
|
||||||
|
foreach ($this->pool->getPackages() as $pkg) {
|
||||||
|
if (isset($pkg->getRequires()[$package->getName()])) {
|
||||||
|
$requirers[] = $pkg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($requirers) {
|
||||||
|
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $requirers, Rule::RULE_PACKAGE_REQUIRES, null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, [
|
$rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, [
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
--TEST--
|
||||||
|
Test that providers are not installed unless really required by something
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{
|
||||||
|
"name": "foo/polyfill",
|
||||||
|
"provide": {
|
||||||
|
"foo/requirement": "1.0.0"
|
||||||
|
},
|
||||||
|
"version": "1.0.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "foo/indirect",
|
||||||
|
"require": {
|
||||||
|
"foo/polyfill": "1.0.0"
|
||||||
|
},
|
||||||
|
"version": "1.0.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "foo/indirect",
|
||||||
|
"version": "1.0.1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "foo/requirement",
|
||||||
|
"require": {
|
||||||
|
"foo/does-not-exist": "1.0.0"
|
||||||
|
},
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"foo/requirement": "1.0.0",
|
||||||
|
"foo/indirect": "^1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--RUN--
|
||||||
|
update
|
||||||
|
|
||||||
|
--EXPECT--
|
||||||
|
Installing foo/polyfill (1.0.0)
|
||||||
|
Installing foo/indirect (1.0.0)
|
Loading…
Reference in New Issue