2011-04-05 15:37:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2011-04-16 12:42:35 +00:00
|
|
|
* This file is part of Composer.
|
2011-04-05 15:37:19 +00:00
|
|
|
*
|
2011-04-16 12:42:35 +00:00
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
2011-04-05 15:37:19 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
namespace Composer\Test\DependencyResolver;
|
|
|
|
|
2011-05-23 00:18:11 +00:00
|
|
|
use Composer\Repository\ArrayRepository;
|
2011-04-05 15:37:19 +00:00
|
|
|
use Composer\DependencyResolver\DefaultPolicy;
|
|
|
|
use Composer\DependencyResolver\Pool;
|
|
|
|
use Composer\DependencyResolver\Request;
|
|
|
|
use Composer\DependencyResolver\Solver;
|
2012-02-18 23:15:23 +00:00
|
|
|
use Composer\DependencyResolver\SolverProblemsException;
|
2011-05-23 00:18:11 +00:00
|
|
|
use Composer\Package\Link;
|
2011-11-20 14:06:12 +00:00
|
|
|
use Composer\Test\TestCase;
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2011-11-20 14:06:12 +00:00
|
|
|
class SolverTest extends TestCase
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-08-05 08:08:21 +00:00
|
|
|
protected $pool;
|
|
|
|
protected $repo;
|
|
|
|
protected $repoInstalled;
|
|
|
|
protected $request;
|
|
|
|
protected $policy;
|
|
|
|
|
|
|
|
public function setUp()
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->pool = new Pool;
|
|
|
|
$this->repo = new ArrayRepository;
|
|
|
|
$this->repoInstalled = new ArrayRepository;
|
|
|
|
|
|
|
|
$this->request = new Request($this->pool);
|
|
|
|
$this->policy = new DefaultPolicy;
|
|
|
|
$this->solver = new Solver($this->policy, $this->pool, $this->repoInstalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSolverInstallSingle()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-04-27 16:13:37 +00:00
|
|
|
public function testSolverRemoveIfNotInstalled()
|
|
|
|
{
|
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'remove', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-02-19 13:55:14 +00:00
|
|
|
public function testInstallNonExistingPackageFails()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($this->getPackage('A', '1.0'));
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-06-20 17:04:21 +00:00
|
|
|
$this->request->install('B', $this->getVersionConstraint('==', '1'));
|
2012-02-19 13:55:14 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
$transaction = $this->solver->solve($this->request);
|
2012-03-18 19:41:10 +00:00
|
|
|
$this->fail('Unsolvable conflict did not result in exception.');
|
2012-02-19 13:55:14 +00:00
|
|
|
} catch (SolverProblemsException $e) {
|
2012-03-18 19:41:10 +00:00
|
|
|
$problems = $e->getProblems();
|
|
|
|
$this->assertEquals(1, count($problems));
|
2012-07-04 12:28:15 +00:00
|
|
|
$this->assertEquals("\n - The requested package b == 1 could not be found.", $problems[0]->getPrettyString());
|
2012-02-19 13:55:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-06 09:11:45 +00:00
|
|
|
public function testSolverInstallSamePackageFromDifferentRepositories()
|
|
|
|
{
|
|
|
|
$repo1 = new ArrayRepository;
|
|
|
|
$repo2 = new ArrayRepository;
|
|
|
|
|
|
|
|
$repo1->addPackage($foo1 = $this->getPackage('foo', '1'));
|
|
|
|
$repo2->addPackage($foo2 = $this->getPackage('foo', '1'));
|
|
|
|
|
|
|
|
$this->pool->addRepository($this->repoInstalled);
|
|
|
|
$this->pool->addRepository($repo1);
|
|
|
|
$this->pool->addRepository($repo2);
|
|
|
|
|
|
|
|
$this->request->install('foo');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $foo1),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
public function testSolverInstallWithDeps()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), 'requires')));
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->reposComplete();
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->request->install('A');
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageB),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2012-06-19 01:08:36 +00:00
|
|
|
public function testSolverInstallHonoursNotEqualOperator()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageB11 = $this->getPackage('B', '1.1'));
|
|
|
|
$this->repo->addPackage($newPackageB12 = $this->getPackage('B', '1.2'));
|
|
|
|
$this->repo->addPackage($newPackageB13 = $this->getPackage('B', '1.3'));
|
|
|
|
|
|
|
|
$packageA->setRequires(array(
|
|
|
|
new Link('A', 'B', $this->getVersionConstraint('<=', '1.3'), 'requires'),
|
|
|
|
new Link('A', 'B', $this->getVersionConstraint('<>', '1.3'), 'requires'),
|
|
|
|
new Link('A', 'B', $this->getVersionConstraint('!=', '1.2'), 'requires'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $newPackageB11),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-06-04 21:30:55 +00:00
|
|
|
public function testSolverInstallWithDepsInOrder()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($packageC = $this->getPackage('C', '1.0'));
|
|
|
|
|
|
|
|
$packageB->setRequires(array(
|
|
|
|
new Link('B', 'A', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
|
|
|
new Link('B', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
|
|
|
));
|
|
|
|
$packageC->setRequires(array(
|
|
|
|
new Link('C', 'A', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
$this->request->install('B');
|
|
|
|
$this->request->install('C');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
array('job' => 'install', 'package' => $packageC),
|
|
|
|
array('job' => 'install', 'package' => $packageB),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
public function testSolverInstallInstalled()
|
2011-08-20 22:19:47 +00:00
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repoInstalled->addPackage($this->getPackage('A', '1.0'));
|
2011-08-20 22:19:47 +00:00
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSolverInstallInstalledWithAlternative()
|
2011-08-05 08:08:21 +00:00
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($this->getPackage('A', '1.0'));
|
|
|
|
$this->repoInstalled->addPackage($this->getPackage('A', '1.0'));
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSolverRemoveSingle()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->remove('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'remove', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSolverRemoveUninstalled()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($this->getPackage('A', '1.0'));
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->remove('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array());
|
|
|
|
}
|
|
|
|
|
2012-01-15 13:15:53 +00:00
|
|
|
public function testSolverUpdateDoesOnlyUpdate()
|
|
|
|
{
|
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repoInstalled->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '1.0.0.0'), 'requires')));
|
2012-01-15 13:15:53 +00:00
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$this->request->install('A', $this->getVersionConstraint('=', '1.0.0.0'));
|
|
|
|
$this->request->install('B', $this->getVersionConstraint('=', '1.1.0.0'));
|
|
|
|
$this->request->update('A', $this->getVersionConstraint('=', '1.0.0.0'));
|
|
|
|
$this->request->update('B', $this->getVersionConstraint('=', '1.0.0.0'));
|
2012-01-15 13:15:53 +00:00
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'update', 'from' => $packageB, 'to' => $newPackageB),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
public function testSolverUpdateSingle()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.1'));
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-04-27 16:13:37 +00:00
|
|
|
$this->request->install('A');
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->request->update('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
2011-08-20 22:38:31 +00:00
|
|
|
array('job' => 'update', 'from' => $packageA, 'to' => $newPackageA),
|
2011-08-05 08:08:21 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-02-19 15:59:04 +00:00
|
|
|
public function testSolverUpdateAll()
|
|
|
|
{
|
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repoInstalled->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.1'));
|
|
|
|
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
|
|
|
|
|
|
|
|
$packageA->setRequires(array(new Link('A', 'B', null, 'requires')));
|
2012-04-27 16:13:37 +00:00
|
|
|
$newPackageA->setRequires(array(new Link('A', 'B', null, 'requires')));
|
2012-02-19 15:59:04 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
$this->request->updateAll();
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'update', 'from' => $packageB, 'to' => $newPackageB),
|
|
|
|
array('job' => 'update', 'from' => $packageA, 'to' => $newPackageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
public function testSolverUpdateCurrent()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repoInstalled->addPackage($this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($this->getPackage('A', '1.0'));
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-04-27 16:13:37 +00:00
|
|
|
$this->request->install('A');
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->request->update('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array());
|
|
|
|
}
|
|
|
|
|
2012-02-18 15:55:45 +00:00
|
|
|
public function testSolverUpdateOnlyUpdatesSelectedPackage()
|
|
|
|
{
|
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repoInstalled->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($packageAnewer = $this->getPackage('A', '1.1'));
|
|
|
|
$this->repo->addPackage($packageBnewer = $this->getPackage('B', '1.1'));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-04-27 16:13:37 +00:00
|
|
|
$this->request->install('A');
|
|
|
|
$this->request->install('B');
|
2012-02-18 15:55:45 +00:00
|
|
|
$this->request->update('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'update', 'from' => $packageA, 'to' => $packageAnewer),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-12-24 13:15:10 +00:00
|
|
|
public function testSolverUpdateConstrained()
|
|
|
|
{
|
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.2'));
|
|
|
|
$this->repo->addPackage($this->getPackage('A', '2.0'));
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$this->request->install('A', $this->getVersionConstraint('<', '2.0.0.0'));
|
2011-12-24 13:15:10 +00:00
|
|
|
$this->request->update('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(array(
|
|
|
|
'job' => 'update',
|
|
|
|
'from' => $packageA,
|
|
|
|
'to' => $newPackageA,
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSolverUpdateFullyConstrained()
|
|
|
|
{
|
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.2'));
|
|
|
|
$this->repo->addPackage($this->getPackage('A', '2.0'));
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$this->request->install('A', $this->getVersionConstraint('<', '2.0.0.0'));
|
|
|
|
$this->request->update('A', $this->getVersionConstraint('=', '1.0.0.0'));
|
2012-02-18 15:55:45 +00:00
|
|
|
|
|
|
|
$this->checkSolverResult(array(array(
|
|
|
|
'job' => 'update',
|
|
|
|
'from' => $packageA,
|
|
|
|
'to' => $newPackageA,
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSolverUpdateFullyConstrainedPrunesInstalledPackages()
|
|
|
|
{
|
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
2012-04-27 16:13:37 +00:00
|
|
|
$this->repoInstalled->addPackage($packageB = $this->getPackage('B', '1.0'));
|
2012-02-18 15:55:45 +00:00
|
|
|
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.2'));
|
|
|
|
$this->repo->addPackage($this->getPackage('A', '2.0'));
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$this->request->install('A', $this->getVersionConstraint('<', '2.0.0.0'));
|
|
|
|
$this->request->update('A', $this->getVersionConstraint('=', '1.0.0.0'));
|
2011-12-24 13:15:10 +00:00
|
|
|
|
2012-04-27 16:13:37 +00:00
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array(
|
|
|
|
'job' => 'update',
|
|
|
|
'from' => $packageA,
|
|
|
|
'to' => $newPackageA,
|
2012-06-04 21:19:32 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'job' => 'remove',
|
|
|
|
'package' => $packageB,
|
|
|
|
),
|
|
|
|
));
|
2011-12-24 13:15:10 +00:00
|
|
|
}
|
|
|
|
|
2011-08-21 10:30:06 +00:00
|
|
|
public function testSolverAllJobs()
|
2011-08-05 08:08:21 +00:00
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repoInstalled->addPackage($packageD = $this->getPackage('D', '1.0'));
|
|
|
|
$this->repoInstalled->addPackage($oldPackageC = $this->getPackage('C', '1.0'));
|
|
|
|
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '2.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
|
|
|
|
$this->repo->addPackage($packageC = $this->getPackage('C', '1.1'));
|
|
|
|
$this->repo->addPackage($this->getPackage('D', '1.0'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), 'requires')));
|
2011-08-05 08:08:21 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
2012-04-27 16:13:37 +00:00
|
|
|
$this->request->install('C');
|
2011-08-05 08:08:21 +00:00
|
|
|
$this->request->update('C');
|
|
|
|
$this->request->remove('D');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
2011-08-20 22:38:31 +00:00
|
|
|
array('job' => 'update', 'from' => $oldPackageC, 'to' => $packageC),
|
2011-08-05 08:08:21 +00:00
|
|
|
array('job' => 'install', 'package' => $packageB),
|
2011-08-20 22:38:31 +00:00
|
|
|
array('job' => 'install', 'package' => $packageA),
|
2012-06-04 21:19:32 +00:00
|
|
|
array('job' => 'remove', 'package' => $packageD),
|
2011-08-05 08:08:21 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-21 10:30:06 +00:00
|
|
|
public function testSolverThreeAlternativeRequireAndConflict()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '2.0'));
|
|
|
|
$this->repo->addPackage($middlePackageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
|
|
|
|
$this->repo->addPackage($oldPackageB = $this->getPackage('B', '0.9'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), 'requires')));
|
|
|
|
$packageA->setConflicts(array(new Link('A', 'B', $this->getVersionConstraint('<', '1.0'), 'conflicts')));
|
2011-08-21 10:30:06 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $middlePackageB),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-21 11:08:34 +00:00
|
|
|
public function testSolverObsolete()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repoInstalled->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
2011-08-21 11:08:34 +00:00
|
|
|
$packageB->setReplaces(array(new Link('B', 'A', null)));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('B');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'update', 'from' => $packageA, 'to' => $packageB),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-21 03:05:11 +00:00
|
|
|
public function testInstallOneOfTwoAlternatives()
|
2011-08-05 08:17:07 +00:00
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('A', '1.0'));
|
2011-08-21 03:05:11 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
2011-10-22 15:20:45 +00:00
|
|
|
array('job' => 'install', 'package' => $packageA),
|
2011-08-21 03:05:11 +00:00
|
|
|
));
|
|
|
|
}
|
2011-08-05 08:17:07 +00:00
|
|
|
|
2011-09-09 08:28:50 +00:00
|
|
|
public function testInstallProvider()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
|
|
|
$packageQ->setProvides(array(new Link('Q', 'B', $this->getVersionConstraint('=', '1.0'), 'provides')));
|
2011-09-09 08:28:50 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
2011-10-15 18:03:55 +00:00
|
|
|
array('job' => 'install', 'package' => $packageQ),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSkipReplacerOfExistingPackage()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
|
|
|
$packageQ->setReplaces(array(new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces')));
|
2011-10-15 18:03:55 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageB),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInstallReplacerOfMissingPackage()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
|
|
|
$packageQ->setReplaces(array(new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces')));
|
2011-10-15 18:03:55 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageQ),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSkipReplacedPackageIfReplacerIsSelected()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
|
|
|
$packageQ->setReplaces(array(new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces')));
|
2011-10-15 18:03:55 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
$this->request->install('Q');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
2011-09-09 08:28:50 +00:00
|
|
|
array('job' => 'install', 'package' => $packageQ),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-11-25 22:32:24 +00:00
|
|
|
public function testPickOlderIfNewerConflicts()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageX = $this->getPackage('X', '1.0'));
|
|
|
|
$packageX->setRequires(array(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('X', 'A', $this->getVersionConstraint('>=', '2.0.0.0'), 'requires'),
|
|
|
|
new Link('X', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), 'requires')));
|
2011-11-25 22:32:24 +00:00
|
|
|
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '2.0.0'));
|
|
|
|
$this->repo->addPackage($newPackageA = $this->getPackage('A', '2.1.0'));
|
|
|
|
$this->repo->addPackage($newPackageB = $this->getPackage('B', '2.1.0'));
|
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), 'requires')));
|
2011-11-25 22:32:24 +00:00
|
|
|
|
|
|
|
// new package A depends on version of package B that does not exist
|
|
|
|
// => new package A is not installable
|
2012-02-19 14:55:44 +00:00
|
|
|
$newPackageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '2.2.0.0'), 'requires')));
|
2011-11-25 22:32:24 +00:00
|
|
|
|
|
|
|
// add a package S replacing both A and B, so that S and B or S and A cannot be simultaneously installed
|
|
|
|
// but an alternative option for A and B both exists
|
|
|
|
// this creates a more difficult so solve conflict
|
|
|
|
$this->repo->addPackage($packageS = $this->getPackage('S', '2.0.0'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageS->setReplaces(array(new Link('S', 'A', $this->getVersionConstraint('>=', '2.0.0.0'), 'replaces'), new Link('S', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), 'replaces')));
|
2011-11-25 22:32:24 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('X');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $newPackageB),
|
2012-06-04 23:05:41 +00:00
|
|
|
array('job' => 'install', 'package' => $packageA),
|
2011-11-25 22:32:24 +00:00
|
|
|
array('job' => 'install', 'package' => $packageX),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-09-09 08:28:50 +00:00
|
|
|
public function testInstallCircularRequire()
|
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB1 = $this->getPackage('B', '0.9'));
|
|
|
|
$this->repo->addPackage($packageB2 = $this->getPackage('B', '1.1'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
|
|
|
$packageB2->setRequires(array(new Link('B', 'A', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
2011-09-09 08:28:50 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageB2),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-09-25 21:50:54 +00:00
|
|
|
public function testInstallAlternativeWithCircularRequire()
|
2011-09-09 08:28:50 +00:00
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($packageC = $this->getPackage('C', '1.0'));
|
|
|
|
$this->repo->addPackage($packageD = $this->getPackage('D', '1.0'));
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageA->setRequires(array(new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
|
|
|
$packageB->setRequires(array(new Link('B', 'Virtual', $this->getVersionConstraint('>=', '1.0'), 'requires')));
|
2012-02-19 19:08:15 +00:00
|
|
|
$packageC->setProvides(array(new Link('C', 'Virtual', $this->getVersionConstraint('==', '1.0'), 'provides')));
|
|
|
|
$packageD->setProvides(array(new Link('D', 'Virtual', $this->getVersionConstraint('==', '1.0'), 'provides')));
|
|
|
|
|
|
|
|
$packageC->setRequires(array(new Link('C', 'A', $this->getVersionConstraint('==', '1.0'), 'requires')));
|
|
|
|
$packageD->setRequires(array(new Link('D', 'A', $this->getVersionConstraint('==', '1.0'), 'requires')));
|
2011-09-09 08:28:50 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2011-09-25 21:50:54 +00:00
|
|
|
$this->request->install('A');
|
2011-09-09 08:28:50 +00:00
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
2011-09-25 21:50:54 +00:00
|
|
|
array('job' => 'install', 'package' => $packageB),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
2012-06-04 23:05:41 +00:00
|
|
|
array('job' => 'install', 'package' => $packageC),
|
2012-02-18 11:33:55 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-02-18 11:37:45 +00:00
|
|
|
* If a replacer D replaces B and C with C not otherwise available,
|
|
|
|
* D must be installed instead of the original B.
|
|
|
|
*/
|
2012-02-18 11:33:55 +00:00
|
|
|
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(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
|
|
|
new Link('A', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
2012-02-18 11:33:55 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
$packageD->setReplaces(array(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('D', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces'),
|
|
|
|
new Link('D', 'C', $this->getVersionConstraint('>=', '1.0'), 'replaces'),
|
2012-02-18 11:33:55 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
$packageD2->setReplaces(array(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('D', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces'),
|
|
|
|
new Link('D', 'C', $this->getVersionConstraint('>=', '1.0'), 'replaces'),
|
2012-02-18 11:33:55 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageD2),
|
|
|
|
array('job' => 'install', 'package' => $packageA),
|
2011-09-09 08:28:50 +00:00
|
|
|
));
|
2011-09-25 21:50:54 +00:00
|
|
|
}
|
2011-09-09 08:28:50 +00:00
|
|
|
|
2012-02-19 14:35:13 +00:00
|
|
|
public function testIssue265()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA1 = $this->getPackage('A', '2.0.999999-dev'));
|
|
|
|
$this->repo->addPackage($packageA2 = $this->getPackage('A', '2.1-dev'));
|
|
|
|
$this->repo->addPackage($packageA3 = $this->getPackage('A', '2.2-dev'));
|
|
|
|
$this->repo->addPackage($packageB1 = $this->getPackage('B', '2.0.10'));
|
|
|
|
$this->repo->addPackage($packageB2 = $this->getPackage('B', '2.0.9'));
|
|
|
|
$this->repo->addPackage($packageC = $this->getPackage('C', '2.0-dev'));
|
|
|
|
$this->repo->addPackage($packageD = $this->getPackage('D', '2.0.9'));
|
|
|
|
|
|
|
|
$packageC->setRequires(array(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('C', 'A', $this->getVersionConstraint('>=', '2.0'), 'requires'),
|
|
|
|
new Link('C', 'D', $this->getVersionConstraint('>=', '2.0'), 'requires'),
|
2012-02-19 14:35:13 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
$packageD->setRequires(array(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('D', 'A', $this->getVersionConstraint('>=', '2.1'), 'requires'),
|
|
|
|
new Link('D', 'B', $this->getVersionConstraint('>=', '2.0-dev'), 'requires'),
|
2012-02-19 14:35:13 +00:00
|
|
|
));
|
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageB1->setRequires(array(new Link('B', 'A', $this->getVersionConstraint('==', '2.1.0.0-dev'), 'requires')));
|
|
|
|
$packageB2->setRequires(array(new Link('B', 'A', $this->getVersionConstraint('==', '2.1.0.0-dev'), 'requires')));
|
2012-02-19 14:35:13 +00:00
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$packageB2->setReplaces(array(new Link('B', 'D', $this->getVersionConstraint('==', '2.0.9.0'), 'replaces')));
|
2012-02-19 14:35:13 +00:00
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
2012-02-19 14:55:44 +00:00
|
|
|
$this->request->install('C', $this->getVersionConstraint('==', '2.0.0.0-dev'));
|
2012-02-19 14:35:13 +00:00
|
|
|
|
|
|
|
$this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
|
|
|
|
|
|
|
|
$this->solver->solve($this->request);
|
|
|
|
}
|
|
|
|
|
2012-02-18 23:15:23 +00:00
|
|
|
public function testConflictResultEmpty()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));;
|
|
|
|
|
|
|
|
$packageA->setConflicts(array(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'conflicts'),
|
2012-02-18 23:15:23 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
$this->request->install('B');
|
|
|
|
|
|
|
|
try {
|
|
|
|
$transaction = $this->solver->solve($this->request);
|
2012-03-18 19:41:10 +00:00
|
|
|
$this->fail('Unsolvable conflict did not result in exception.');
|
2012-02-18 23:15:23 +00:00
|
|
|
} catch (SolverProblemsException $e) {
|
2012-03-18 19:41:10 +00:00
|
|
|
$problems = $e->getProblems();
|
|
|
|
$this->assertEquals(1, count($problems));
|
2012-06-20 17:04:21 +00:00
|
|
|
|
|
|
|
$msg = "\n";
|
|
|
|
$msg .= " Problem 1\n";
|
|
|
|
$msg .= " - Installation request for a -> satisfiable by A 1.0.\n";
|
|
|
|
$msg .= " - B 1.0 conflicts with A 1.0.\n";
|
|
|
|
$msg .= " - Installation request for b -> satisfiable by B 1.0.\n";
|
|
|
|
$this->assertEquals($msg, $e->getMessage());
|
2012-02-18 23:15:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUnsatisfiableRequires()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
|
|
|
|
$packageA->setRequires(array(
|
2012-02-19 14:55:44 +00:00
|
|
|
new Link('A', 'B', $this->getVersionConstraint('>=', '2.0'), 'requires'),
|
2012-02-18 23:15:23 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
try {
|
|
|
|
$transaction = $this->solver->solve($this->request);
|
2012-03-18 19:41:10 +00:00
|
|
|
$this->fail('Unsolvable conflict did not result in exception.');
|
2012-02-18 23:15:23 +00:00
|
|
|
} catch (SolverProblemsException $e) {
|
2012-03-18 19:41:10 +00:00
|
|
|
$problems = $e->getProblems();
|
|
|
|
$this->assertEquals(1, count($problems));
|
2012-02-19 14:30:53 +00:00
|
|
|
// TODO assert problem properties
|
2012-06-20 17:04:21 +00:00
|
|
|
|
|
|
|
$msg = "\n";
|
|
|
|
$msg .= " Problem 1\n";
|
|
|
|
$msg .= " - Installation request for a -> satisfiable by A 1.0.\n";
|
2012-07-04 13:57:51 +00:00
|
|
|
$msg .= " - A 1.0 requires b >= 2.0 -> no matching package found.\n\n";
|
|
|
|
$msg .= "Potential causes:\n";
|
|
|
|
$msg .= " - A typo in the package name\n";
|
|
|
|
$msg .= " - The package is not available in a stable-enough version according to your minimum-stability setting\n";
|
2012-10-08 18:05:42 +00:00
|
|
|
$msg .= " see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.\n\n";
|
|
|
|
$msg .= "Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
|
2012-06-20 17:04:21 +00:00
|
|
|
$this->assertEquals($msg, $e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testRequireMismatchException()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB2 = $this->getPackage('B', '0.9'));
|
|
|
|
$this->repo->addPackage($packageC = $this->getPackage('C', '1.0'));
|
|
|
|
$this->repo->addPackage($packageD = $this->getPackage('D', '1.0'));
|
|
|
|
|
|
|
|
$packageA->setRequires(array(
|
|
|
|
new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
|
|
|
));
|
|
|
|
$packageB->setRequires(array(
|
|
|
|
new Link('B', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
|
|
|
));
|
|
|
|
$packageC->setRequires(array(
|
|
|
|
new Link('C', 'D', $this->getVersionConstraint('>=', '1.0'), 'requires'),
|
|
|
|
));
|
|
|
|
$packageD->setRequires(array(
|
|
|
|
new Link('D', 'B', $this->getVersionConstraint('<', '1.0'), 'requires'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A');
|
|
|
|
|
|
|
|
try {
|
|
|
|
$transaction = $this->solver->solve($this->request);
|
|
|
|
$this->fail('Unsolvable conflict did not result in exception.');
|
|
|
|
} catch (SolverProblemsException $e) {
|
|
|
|
$problems = $e->getProblems();
|
|
|
|
$this->assertEquals(1, count($problems));
|
|
|
|
|
|
|
|
$msg = "\n";
|
|
|
|
$msg .= " Problem 1\n";
|
|
|
|
$msg .= " - C 1.0 requires d >= 1.0 -> satisfiable by D 1.0.\n";
|
|
|
|
$msg .= " - D 1.0 requires b < 1.0 -> satisfiable by B 0.9.\n";
|
|
|
|
$msg .= " - B 1.0 requires c >= 1.0 -> satisfiable by C 1.0.\n";
|
|
|
|
$msg .= " - Can only install one of: B 0.9, B 1.0.\n";
|
|
|
|
$msg .= " - A 1.0 requires b >= 1.0 -> satisfiable by B 1.0.\n";
|
|
|
|
$msg .= " - Installation request for a -> satisfiable by A 1.0.\n";
|
|
|
|
$this->assertEquals($msg, $e->getMessage());
|
2012-02-18 23:15:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-01 20:26:10 +00:00
|
|
|
public function testLearnLiteralsWithSortedRuleLiterals()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageTwig2 = $this->getPackage('twig/twig', '2.0'));
|
|
|
|
$this->repo->addPackage($packageTwig16 = $this->getPackage('twig/twig', '1.6'));
|
|
|
|
$this->repo->addPackage($packageTwig15 = $this->getPackage('twig/twig', '1.5'));
|
|
|
|
$this->repo->addPackage($packageSymfony = $this->getPackage('symfony/symfony', '2.0'));
|
|
|
|
$this->repo->addPackage($packageTwigBridge = $this->getPackage('symfony/twig-bridge', '2.0'));
|
|
|
|
|
|
|
|
$packageTwigBridge->setRequires(array(
|
|
|
|
new Link('symfony/twig-bridge', 'twig/twig', $this->getVersionConstraint('<', '2.0'), 'requires'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$packageSymfony->setReplaces(array(
|
|
|
|
new Link('symfony/symfony', 'symfony/twig-bridge', $this->getVersionConstraint('==', '2.0'), 'replaces'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('symfony/twig-bridge');
|
|
|
|
$this->request->install('twig/twig');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageTwig16),
|
|
|
|
array('job' => 'install', 'package' => $packageTwigBridge),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-04-27 17:41:53 +00:00
|
|
|
public function testInstallRecursiveAliasDependencies()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '2.0'));
|
|
|
|
$this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0'));
|
|
|
|
|
|
|
|
$packageA2->setRequires(array(
|
|
|
|
new Link('A', 'B', $this->getVersionConstraint('==', '2.0'), 'requires', '== 2.0'),
|
|
|
|
));
|
|
|
|
$packageB->setRequires(array(
|
|
|
|
new Link('B', 'A', $this->getVersionConstraint('>=', '2.0'), 'requires'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->repo->addPackage($packageA2Alias = $this->getAliasPackage($packageA2, '1.1'));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A', $this->getVersionConstraint('==', '1.1.0.0'));
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
|
|
|
array('job' => 'install', 'package' => $packageA2),
|
2012-06-04 23:05:41 +00:00
|
|
|
array('job' => 'install', 'package' => $packageB),
|
2012-04-27 17:41:53 +00:00
|
|
|
array('job' => 'install', 'package' => $packageA2Alias),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInstallDevAlias()
|
|
|
|
{
|
|
|
|
$this->repo->addPackage($packageA = $this->getPackage('A', '2.0'));
|
|
|
|
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
|
|
|
|
|
|
|
|
$packageB->setRequires(array(
|
|
|
|
new Link('B', 'A', $this->getVersionConstraint('<', '2.0'), 'requires'),
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->repo->addPackage($packageAAlias = $this->getAliasPackage($packageA, '1.1'));
|
|
|
|
|
|
|
|
$this->reposComplete();
|
|
|
|
|
|
|
|
$this->request->install('A', $this->getVersionConstraint('==', '2.0'));
|
|
|
|
$this->request->install('B');
|
|
|
|
|
|
|
|
$this->checkSolverResult(array(
|
2012-06-04 23:05:41 +00:00
|
|
|
array('job' => 'install', 'package' => $packageA),
|
2012-04-27 17:41:53 +00:00
|
|
|
array('job' => 'install', 'package' => $packageAAlias),
|
|
|
|
array('job' => 'install', 'package' => $packageB),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-08-05 08:08:21 +00:00
|
|
|
protected function reposComplete()
|
|
|
|
{
|
|
|
|
$this->pool->addRepository($this->repoInstalled);
|
|
|
|
$this->pool->addRepository($this->repo);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function checkSolverResult(array $expected)
|
|
|
|
{
|
2011-09-23 23:29:22 +00:00
|
|
|
$transaction = $this->solver->solve($this->request);
|
|
|
|
|
|
|
|
$result = array();
|
|
|
|
foreach ($transaction as $operation) {
|
|
|
|
if ('update' === $operation->getJobType()) {
|
2011-09-25 11:40:12 +00:00
|
|
|
$result[] = array(
|
|
|
|
'job' => 'update',
|
|
|
|
'from' => $operation->getInitialPackage(),
|
|
|
|
'to' => $operation->getTargetPackage()
|
|
|
|
);
|
2011-09-23 23:29:22 +00:00
|
|
|
} else {
|
2011-09-25 11:40:12 +00:00
|
|
|
$job = ('uninstall' === $operation->getJobType() ? 'remove' : 'install');
|
|
|
|
$result[] = array(
|
|
|
|
'job' => $job,
|
|
|
|
'package' => $operation->getPackage()
|
|
|
|
);
|
2011-09-23 23:29:22 +00:00
|
|
|
}
|
2011-08-20 22:19:47 +00:00
|
|
|
}
|
|
|
|
|
2011-05-23 00:23:21 +00:00
|
|
|
$this->assertEquals($expected, $result);
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|
|
|
|
}
|