Skip to content

Commit

Permalink
The Solver Request no longer depends on the Pool
Browse files Browse the repository at this point in the history
  • Loading branch information
naderman committed Apr 30, 2015
1 parent 6d76142 commit b4ed331
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/Composer/DependencyResolver/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
class Request
{
protected $jobs;
protected $pool;

public function __construct(Pool $pool)
public function __construct()
{
$this->pool = $pool;
$this->jobs = array();
}

Expand Down
8 changes: 4 additions & 4 deletions src/Composer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function run()
$pool->addRepository($installedRepo, $aliases);

// creating requirements request
$request = $this->createRequest($pool, $this->package, $platformRepo);
$request = $this->createRequest($this->package, $platformRepo);
$request->updateAll();
foreach ($this->package->getRequires() as $link) {
$request->install($link->getTarget(), $link->getConstraint());
Expand Down Expand Up @@ -398,7 +398,7 @@ protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases
}

// creating requirements request
$request = $this->createRequest($pool, $this->package, $platformRepo);
$request = $this->createRequest($this->package, $platformRepo);

if (!$installFromLock) {
// remove unstable packages from the localRepo if they don't match the current stability settings
Expand Down Expand Up @@ -735,9 +735,9 @@ private function createPolicy()
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->setPrettyString($rootPackage->getPrettyVersion());
Expand Down
14 changes: 3 additions & 11 deletions tests/Composer/Test/DependencyResolver/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
namespace Composer\Test\DependencyResolver;

use Composer\DependencyResolver\Request;
use Composer\DependencyResolver\Pool;
use Composer\Repository\ArrayRepository;
use Composer\TestCase;

class RequestTest extends TestCase
{
public function testRequestInstallAndRemove()
{
$pool = new Pool;
$repo = new ArrayRepository;
$foo = $this->getPackage('foo', '1');
$bar = $this->getPackage('bar', '1');
Expand All @@ -30,9 +28,8 @@ public function testRequestInstallAndRemove()
$repo->addPackage($foo);
$repo->addPackage($bar);
$repo->addPackage($foobar);
$pool->addRepository($repo);

$request = new Request($pool);
$request = new Request();
$request->install('foo');
$request->fix('bar');
$request->remove('foobar');
Expand All @@ -48,7 +45,6 @@ public function testRequestInstallAndRemove()

public function testRequestInstallSamePackageFromDifferentRepositories()
{
$pool = new Pool;
$repo1 = new ArrayRepository;
$repo2 = new ArrayRepository;

Expand All @@ -58,10 +54,7 @@ public function testRequestInstallSamePackageFromDifferentRepositories()
$repo1->addPackage($foo1);
$repo2->addPackage($foo2);

$pool->addRepository($repo1);
$pool->addRepository($repo2);

$request = new Request($pool);
$request = new Request();
$request->install('foo', $constraint = $this->getVersionConstraint('=', '1'));

$this->assertEquals(
Expand All @@ -74,8 +67,7 @@ public function testRequestInstallSamePackageFromDifferentRepositories()

public function testUpdateAll()
{
$pool = new Pool;
$request = new Request($pool);
$request = new Request();

$request->updateAll();

Expand Down

0 comments on commit b4ed331

Please sign in to comment.