From da02c53540c6f7a13c162054203465aa0c7ebdee Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 5 May 2015 19:44:07 +0200 Subject: [PATCH] Update the composer repository whatprovides test to a loadrecursively test --- src/Composer/DependencyResolver/Solver.php | 4 +-- .../Repository/ComposerRepositoryTest.php | 32 ++++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 2ad1d2be2..7dd947acf 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -174,12 +174,12 @@ class Solver foreach ($this->jobs as $job) { switch ($job['cmd']) { case 'install': - $packageNames[] = $job['packageName']; + $packageNames[$job['packageName']] = true; break; } } - $this->pool->loadRecursively($packageNames, true); + $this->pool->loadRecursively(array_keys($packageNames), true); $this->rules = $this->ruleSetGenerator->getRulesFor($this->jobs, $this->installedMap, $ignorePlatformReqs); $this->checkForRootRequireProblems($ignorePlatformReqs); diff --git a/tests/Composer/Test/Repository/ComposerRepositoryTest.php b/tests/Composer/Test/Repository/ComposerRepositoryTest.php index 3066e2540..4e4fc99bb 100644 --- a/tests/Composer/Test/Repository/ComposerRepositoryTest.php +++ b/tests/Composer/Test/Repository/ComposerRepositoryTest.php @@ -96,8 +96,8 @@ class ComposerRepositoryTest extends TestCase ); } - public function testWhatProvides() - {/* + public function testLoadRecursively() + { $repo = $this->getMockBuilder('Composer\Repository\ComposerRepository') ->disableOriginalConstructor() ->setMethods(array('fetchFile')) @@ -144,25 +144,19 @@ class ComposerRepositoryTest extends TestCase ) ))); - $pool = $this->getMock('Composer\DependencyResolver\Pool'); - $pool->expects($this->any()) - ->method('isPackageAcceptable') - ->will($this->returnValue(true)); - $versionParser = new VersionParser(); - $repo->setRootAliases(array( - 'a' => array( - $versionParser->normalize('0.6') => array('alias' => 'dev-feature', 'alias_normalized' => $versionParser->normalize('dev-feature')), - $versionParser->normalize('1.1.x-dev') => array('alias' => '1.0', 'alias_normalized' => $versionParser->normalize('1.0')), - ), - )); - $packages = $repo->whatProvides($pool, 'a'); + $that = $this; + $packages = $repo->loadRecursively(array('a'), true, function ($name, $stability) use ($that) { + $this->assertEquals('a', $name); + return true; + }); - $this->assertCount(7, $packages); - $this->assertEquals(array('1', '1-alias', '2', '2-alias', '2-root', '3', '3-root'), array_keys($packages)); - $this->assertInstanceOf('Composer\Package\AliasPackage', $packages['2-root']); - $this->assertSame($packages['2'], $packages['2-root']->getAliasOf()); - $this->assertSame($packages['2'], $packages['2-alias']->getAliasOf());*/ + $this->assertCount(5, $packages); + $this->assertEquals(array('1.0.x-dev', 'dev-master', '1.1.x-dev', 'dev-develop', '0.6'), array_map(function ($p) { + return $p->getPrettyVersion(); + }, $packages)); + $this->assertInstanceOf('Composer\Package\AliasPackage', $packages[2]); + $this->assertSame($packages[3], $packages[2]->getAliasOf()); } }