diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index c40789c1f..dbfafd243 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -57,6 +57,9 @@ class Solver /** @var array */ protected $learnedWhy = array(); + /** @var bool */ + public $testFlagLearnedPositiveLiteral = false; + /** @var IOInterface */ protected $io; @@ -470,6 +473,9 @@ class Solver unset($seen[abs($literal)]); if ($num && 0 === --$num) { + if ($literal < 0) { + $this->testFlagLearnedPositiveLiteral = true; + } $learnedLiterals[0] = -$literal; if (!$l1num) { diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 7094f412d..4dadee7d8 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -891,6 +891,9 @@ class SolverTest extends TestCase $this->request->install('A'); + // check correct setup for assertion later + $this->assertFalse($this->solver->testFlagLearnedPositiveLiteral); + $this->checkSolverResult(array( array('job' => 'install', 'package' => $packageF1), array('job' => 'install', 'package' => $packageD), @@ -900,6 +903,10 @@ class SolverTest extends TestCase array('job' => 'install', 'package' => $packageB), array('job' => 'install', 'package' => $packageA), )); + + // verify that the code path leading to a negative literal resulting in a positive learned literal is actually + // executed + $this->assertTrue($this->solver->testFlagLearnedPositiveLiteral); } protected function reposComplete()