Correct handling of rules with more than 2 literals.
parent
db18e1b560
commit
69ebbf0eac
|
@ -1270,16 +1270,16 @@ class Solver
|
||||||
|
|
||||||
if (sizeof($ruleLiterals) > 2) {
|
if (sizeof($ruleLiterals) > 2) {
|
||||||
foreach ($ruleLiterals as $ruleLiteral) {
|
foreach ($ruleLiterals as $ruleLiteral) {
|
||||||
if (!$otherWatch->equals($ruleLiteral) &&
|
if ($otherWatch !== $ruleLiteral->getId() &&
|
||||||
!$this->decisionsConflict($ruleLiteral)) {
|
!$this->decisionsConflict($ruleLiteral)) {
|
||||||
|
|
||||||
|
|
||||||
if ($literal->equals($rule->getWatch1())) {
|
if ($literal->getId() === $rule->watch1) {
|
||||||
$rule->setWatch1($ruleLiteral);
|
$rule->watch1 = $ruleLiteral->getId();
|
||||||
$rule->setNext1($rule);
|
$rule->next1 = (isset($this->watches[$ruleLiteral->getId()])) ? $this->watches[$ruleLiteral->getId()] : null ;
|
||||||
} else {
|
} else {
|
||||||
$rule->setWatch2($ruleLiteral);
|
$rule->watch2 = $ruleLiteral->getId();
|
||||||
$rule->setNext2($rule);
|
$rule->next2 = (isset($this->watches[$ruleLiteral->getId()])) ? $this->watches[$ruleLiteral->getId()] : null ;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->watches[$ruleLiteral->getId()] = $rule;
|
$this->watches[$ruleLiteral->getId()] = $rule;
|
||||||
|
|
|
@ -139,7 +139,7 @@ class SolverTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->checkSolverResult(array());
|
$this->checkSolverResult(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSolverFull()
|
public function testSolverAllJobs()
|
||||||
{
|
{
|
||||||
$this->repoInstalled->addPackage($packageD = new MemoryPackage('D', '1.0'));
|
$this->repoInstalled->addPackage($packageD = new MemoryPackage('D', '1.0'));
|
||||||
$this->repoInstalled->addPackage($oldPackageC = new MemoryPackage('C', '1.0'));
|
$this->repoInstalled->addPackage($oldPackageC = new MemoryPackage('C', '1.0'));
|
||||||
|
@ -165,6 +165,25 @@ class SolverTest extends \PHPUnit_Framework_TestCase
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSolverThreeAlternativeRequireAndConflict()
|
||||||
|
{
|
||||||
|
$this->repo->addPackage($packageA = new MemoryPackage('A', '2.0'));
|
||||||
|
$this->repo->addPackage($middlePackageB = new MemoryPackage('B', '1.0'));
|
||||||
|
$this->repo->addPackage($newPackageB = new MemoryPackage('B', '1.1'));
|
||||||
|
$this->repo->addPackage($oldPackageB = new MemoryPackage('B', '0.9'));
|
||||||
|
$packageA->setRequires(array(new Link('A', 'B', new VersionConstraint('<', '1.1'), 'requires')));
|
||||||
|
$packageA->setConflicts(array(new Link('A', 'B', new VersionConstraint('<', '1.0'), 'conflicts')));
|
||||||
|
|
||||||
|
$this->reposComplete();
|
||||||
|
|
||||||
|
$this->request->install('A');
|
||||||
|
|
||||||
|
$this->checkSolverResult(array(
|
||||||
|
array('job' => 'install', 'package' => $middlePackageB),
|
||||||
|
array('job' => 'install', 'package' => $packageA),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public function testInstallOneOfTwoAlternatives()
|
public function testInstallOneOfTwoAlternatives()
|
||||||
{
|
{
|
||||||
$this->repo->addPackage($packageA = new MemoryPackage('A', '1.0'));
|
$this->repo->addPackage($packageA = new MemoryPackage('A', '1.0'));
|
||||||
|
|
Loading…
Reference in New Issue