The Solver Request no longer depends on the Pool

main
Nils Adermann 9 years ago
parent 6d76142907
commit b4ed331168

@ -20,11 +20,9 @@ use Composer\Package\LinkConstraint\LinkConstraintInterface;
class Request class Request
{ {
protected $jobs; protected $jobs;
protected $pool;
public function __construct(Pool $pool) public function __construct()
{ {
$this->pool = $pool;
$this->jobs = array(); $this->jobs = array();
} }

@ -287,7 +287,7 @@ class Installer
$pool->addRepository($installedRepo, $aliases); $pool->addRepository($installedRepo, $aliases);
// creating requirements request // creating requirements request
$request = $this->createRequest($pool, $this->package, $platformRepo); $request = $this->createRequest($this->package, $platformRepo);
$request->updateAll(); $request->updateAll();
foreach ($this->package->getRequires() as $link) { foreach ($this->package->getRequires() as $link) {
$request->install($link->getTarget(), $link->getConstraint()); $request->install($link->getTarget(), $link->getConstraint());
@ -398,7 +398,7 @@ class Installer
} }
// creating requirements request // creating requirements request
$request = $this->createRequest($pool, $this->package, $platformRepo); $request = $this->createRequest($this->package, $platformRepo);
if (!$installFromLock) { if (!$installFromLock) {
// remove unstable packages from the localRepo if they don't match the current stability settings // remove unstable packages from the localRepo if they don't match the current stability settings
@ -735,9 +735,9 @@ class Installer
return new DefaultPolicy($preferStable, $preferLowest); return new DefaultPolicy($preferStable, $preferLowest);
} }
private function createRequest(Pool $pool, RootPackageInterface $rootPackage, PlatformRepository $platformRepo) private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo)
{ {
$request = new Request($pool); $request = new Request();
$constraint = new VersionConstraint('=', $rootPackage->getVersion()); $constraint = new VersionConstraint('=', $rootPackage->getVersion());
$constraint->setPrettyString($rootPackage->getPrettyVersion()); $constraint->setPrettyString($rootPackage->getPrettyVersion());

@ -13,7 +13,6 @@
namespace Composer\Test\DependencyResolver; namespace Composer\Test\DependencyResolver;
use Composer\DependencyResolver\Request; use Composer\DependencyResolver\Request;
use Composer\DependencyResolver\Pool;
use Composer\Repository\ArrayRepository; use Composer\Repository\ArrayRepository;
use Composer\TestCase; use Composer\TestCase;
@ -21,7 +20,6 @@ class RequestTest extends TestCase
{ {
public function testRequestInstallAndRemove() public function testRequestInstallAndRemove()
{ {
$pool = new Pool;
$repo = new ArrayRepository; $repo = new ArrayRepository;
$foo = $this->getPackage('foo', '1'); $foo = $this->getPackage('foo', '1');
$bar = $this->getPackage('bar', '1'); $bar = $this->getPackage('bar', '1');
@ -30,9 +28,8 @@ class RequestTest extends TestCase
$repo->addPackage($foo); $repo->addPackage($foo);
$repo->addPackage($bar); $repo->addPackage($bar);
$repo->addPackage($foobar); $repo->addPackage($foobar);
$pool->addRepository($repo);
$request = new Request($pool); $request = new Request();
$request->install('foo'); $request->install('foo');
$request->fix('bar'); $request->fix('bar');
$request->remove('foobar'); $request->remove('foobar');
@ -48,7 +45,6 @@ class RequestTest extends TestCase
public function testRequestInstallSamePackageFromDifferentRepositories() public function testRequestInstallSamePackageFromDifferentRepositories()
{ {
$pool = new Pool;
$repo1 = new ArrayRepository; $repo1 = new ArrayRepository;
$repo2 = new ArrayRepository; $repo2 = new ArrayRepository;
@ -58,10 +54,7 @@ class RequestTest extends TestCase
$repo1->addPackage($foo1); $repo1->addPackage($foo1);
$repo2->addPackage($foo2); $repo2->addPackage($foo2);
$pool->addRepository($repo1); $request = new Request();
$pool->addRepository($repo2);
$request = new Request($pool);
$request->install('foo', $constraint = $this->getVersionConstraint('=', '1')); $request->install('foo', $constraint = $this->getVersionConstraint('=', '1'));
$this->assertEquals( $this->assertEquals(
@ -74,8 +67,7 @@ class RequestTest extends TestCase
public function testUpdateAll() public function testUpdateAll()
{ {
$pool = new Pool; $request = new Request();
$request = new Request($pool);
$request->updateAll(); $request->updateAll();

Loading…
Cancel
Save