From 3b54316e91915ccd063ca359d1b6faa9a4ce266d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 18 Feb 2012 12:33:55 +0100 Subject: [PATCH 1/2] Add a test for the off by one error in solver conflict resolution --- .../Test/DependencyResolver/SolverTest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 7496834e6..57f835c88 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -414,6 +414,42 @@ class SolverTest extends TestCase )); } + /** + * If a replacer D replaces B and C with C not otherwise available, + * D must be installed instead of the original B. + */ + public function testUseReplacerIfNecessary() + { + $this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); + $this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); + $this->repo->addPackage($packageD = $this->getPackage('D', '1.0')); + $this->repo->addPackage($packageD2 = $this->getPackage('D', '1.1')); + + $packageA->setRequires(array( + new Link('A', 'B', new VersionConstraint('>=', '1.0'), 'requires'), + new Link('A', 'C', new VersionConstraint('>=', '1.0'), 'requires'), + )); + + $packageD->setReplaces(array( + new Link('D', 'B', new VersionConstraint('>=', '1.0'), 'replaces'), + new Link('D', 'C', new VersionConstraint('>=', '1.0'), 'replaces'), + )); + + $packageD2->setReplaces(array( + new Link('D', 'B', new VersionConstraint('>=', '1.0'), 'replaces'), + new Link('D', 'C', new VersionConstraint('>=', '1.0'), 'replaces'), + )); + + $this->reposComplete(); + + $this->request->install('A'); + + $this->checkSolverResult(array( + array('job' => 'install', 'package' => $packageD2), + array('job' => 'install', 'package' => $packageA), + )); + } + protected function reposComplete() { $this->pool->addRepository($this->repoInstalled); From 460822fb96c8bbe624bb8d336731a2b0e8093d22 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 18 Feb 2012 12:37:45 +0100 Subject: [PATCH 2/2] Fix indentation of doc comment --- tests/Composer/Test/DependencyResolver/SolverTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 57f835c88..85ef6fc70 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -415,9 +415,9 @@ class SolverTest extends TestCase } /** - * If a replacer D replaces B and C with C not otherwise available, - * D must be installed instead of the original B. - */ + * If a replacer D replaces B and C with C not otherwise available, + * D must be installed instead of the original B. + */ public function testUseReplacerIfNecessary() { $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));