From 40cc5fea1df813ffafdb365a20956ca92ff749bb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 15 Oct 2011 20:03:55 +0200 Subject: [PATCH] Add a few solver tests regarding "replace" --- .../Test/DependencyResolver/SolverTest.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index cd2e0b8a7..ad9291055 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -231,6 +231,60 @@ class SolverTest extends \PHPUnit_Framework_TestCase )); } + public function testSkipReplacerOfExistingPackage() + { + $this->repo->addPackage($packageA = new MemoryPackage('A', '1.0')); + $this->repo->addPackage($packageQ = new MemoryPackage('Q', '1.0')); + $this->repo->addPackage($packageB = new MemoryPackage('B', '1.0')); + $packageA->setRequires(array(new Link('A', 'B', new VersionConstraint('>=', '1.0'), 'requires'))); + $packageQ->setReplaces(array(new Link('Q', 'B', new VersionConstraint('>=', '1.0'), 'replaces'))); + + $this->reposComplete(); + + $this->request->install('A'); + + $this->checkSolverResult(array( + array('job' => 'install', 'package' => $packageB), + array('job' => 'install', 'package' => $packageA), + )); + } + + public function testInstallReplacerOfMissingPackage() + { + $this->repo->addPackage($packageA = new MemoryPackage('A', '1.0')); + $this->repo->addPackage($packageQ = new MemoryPackage('Q', '1.0')); + $packageA->setRequires(array(new Link('A', 'B', new VersionConstraint('>=', '1.0'), 'requires'))); + $packageQ->setReplaces(array(new Link('Q', 'B', new VersionConstraint('>=', '1.0'), 'replaces'))); + + $this->reposComplete(); + + $this->request->install('A'); + + $this->checkSolverResult(array( + array('job' => 'install', 'package' => $packageQ), + array('job' => 'install', 'package' => $packageA), + )); + } + + public function testSkipReplacedPackageIfReplacerIsSelected() + { + $this->repo->addPackage($packageA = new MemoryPackage('A', '1.0')); + $this->repo->addPackage($packageQ = new MemoryPackage('Q', '1.0')); + $this->repo->addPackage($packageB = new MemoryPackage('B', '1.0')); + $packageA->setRequires(array(new Link('A', 'B', new VersionConstraint('>=', '1.0'), 'requires'))); + $packageQ->setReplaces(array(new Link('Q', 'B', new VersionConstraint('>=', '1.0'), 'replaces'))); + + $this->reposComplete(); + + $this->request->install('A'); + $this->request->install('Q'); + + $this->checkSolverResult(array( + array('job' => 'install', 'package' => $packageQ), + array('job' => 'install', 'package' => $packageA), + )); + } + public function testInstallCircularRequire() { $this->repo->addPackage($packageA = new MemoryPackage('A', '1.0'));