mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Move construction of pool from repo set into a pool builder
Pool construction depends on the install request now, so only required packages get loaded, add some structure for future asynchronously loading composer repositories
This commit is contained in:
parent
4c7d271a36
commit
c0f19f6c57
20 changed files with 357 additions and 248 deletions
|
@ -20,6 +20,7 @@ use Composer\DependencyResolver\Request;
|
|||
use Composer\DependencyResolver\Solver;
|
||||
use Composer\DependencyResolver\SolverProblemsException;
|
||||
use Composer\Package\Link;
|
||||
use Composer\Repository\InstalledArrayRepository;
|
||||
use Composer\Repository\RepositorySet;
|
||||
use Composer\TestCase;
|
||||
use Composer\Semver\Constraint\MultiConstraint;
|
||||
|
@ -31,12 +32,13 @@ class SolverTest extends TestCase
|
|||
protected $repoInstalled;
|
||||
protected $request;
|
||||
protected $policy;
|
||||
protected $solver;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->repoSet = new RepositorySet(array());
|
||||
$this->repo = new ArrayRepository;
|
||||
$this->repoInstalled = new ArrayRepository;
|
||||
$this->repoInstalled = new InstalledArrayRepository;
|
||||
|
||||
$this->request = new Request($this->repoSet);
|
||||
$this->policy = new DefaultPolicy;
|
||||
|
@ -71,6 +73,7 @@ class SolverTest extends TestCase
|
|||
|
||||
$this->request->install('B', $this->getVersionConstraint('==', '1'));
|
||||
|
||||
$this->createSolver();
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
|
@ -94,8 +97,6 @@ class SolverTest extends TestCase
|
|||
$this->repoSet->addRepository($repo1);
|
||||
$this->repoSet->addRepository($repo2);
|
||||
|
||||
$this->solver = new Solver($this->policy, $this->repoSet->createPool(), $this->repoInstalled, new NullIO());
|
||||
|
||||
$this->request->install('foo');
|
||||
|
||||
$this->checkSolverResult(array(
|
||||
|
@ -447,6 +448,7 @@ class SolverTest extends TestCase
|
|||
|
||||
// must explicitly pick the provider, so error in this case
|
||||
$this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
|
||||
$this->createSolver();
|
||||
$this->solver->solve($this->request);
|
||||
}
|
||||
|
||||
|
@ -480,6 +482,7 @@ class SolverTest extends TestCase
|
|||
$this->request->install('A');
|
||||
|
||||
$this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
|
||||
$this->createSolver();
|
||||
$this->solver->solve($this->request);
|
||||
}
|
||||
|
||||
|
@ -652,6 +655,7 @@ class SolverTest extends TestCase
|
|||
|
||||
$this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
|
||||
|
||||
$this->createSolver();
|
||||
$this->solver->solve($this->request);
|
||||
}
|
||||
|
||||
|
@ -668,6 +672,7 @@ class SolverTest extends TestCase
|
|||
$this->request->install('A');
|
||||
$this->request->install('B');
|
||||
|
||||
$this->createSolver();
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
|
@ -697,6 +702,7 @@ class SolverTest extends TestCase
|
|||
|
||||
$this->request->install('A');
|
||||
|
||||
$this->createSolver();
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
|
@ -744,6 +750,7 @@ class SolverTest extends TestCase
|
|||
|
||||
$this->request->install('A');
|
||||
|
||||
$this->createSolver();
|
||||
try {
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
$this->fail('Unsolvable conflict did not result in exception.');
|
||||
|
@ -843,12 +850,16 @@ class SolverTest extends TestCase
|
|||
{
|
||||
$this->repoSet->addRepository($this->repoInstalled);
|
||||
$this->repoSet->addRepository($this->repo);
|
||||
}
|
||||
|
||||
$this->solver = new Solver($this->policy, $this->repoSet->createPool(), $this->repoInstalled, new NullIO());
|
||||
protected function createSolver()
|
||||
{
|
||||
$this->solver = new Solver($this->policy, $this->repoSet->createPool($this->request), $this->repoInstalled, new NullIO());
|
||||
}
|
||||
|
||||
protected function checkSolverResult(array $expected)
|
||||
{
|
||||
$this->createSolver();
|
||||
$transaction = $this->solver->solve($this->request);
|
||||
|
||||
$result = array();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue