From c6321e7277d9dc05cf8abe6859e85a1c9cabde6c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 17 Apr 2011 23:45:37 +0200 Subject: [PATCH] Fix tests and invalid use statements --- src/Composer/DependencyResolver/Literal.php | 4 +++- src/Composer/DependencyResolver/Pool.php | 7 ++----- src/Composer/Package/BasePackage.php | 2 +- src/Composer/Package/PackageInterface.php | 6 +++--- tests/Composer/Test/DependencyResolver/LiteralTest.php | 2 +- tests/Composer/Test/DependencyResolver/PoolTest.php | 4 ++-- tests/Composer/Test/DependencyResolver/RequestTest.php | 4 ++-- .../Test/{DependencyResolver => Package}/PackageTest.php | 7 +++---- .../ArrayRepositoryTest.php | 6 +++--- 9 files changed, 20 insertions(+), 22 deletions(-) rename tests/Composer/Test/{DependencyResolver => Package}/PackageTest.php (75%) rename tests/Composer/Test/{DependencyResolver => Repository}/ArrayRepositoryTest.php (79%) diff --git a/src/Composer/DependencyResolver/Literal.php b/src/Composer/DependencyResolver/Literal.php index 5b8fe453b..e1a95514a 100644 --- a/src/Composer/DependencyResolver/Literal.php +++ b/src/Composer/DependencyResolver/Literal.php @@ -12,6 +12,8 @@ namespace Composer\DependencyResolver; +use Composer\Package\PackageInterface; + /** * @author Nils Adermann */ @@ -19,7 +21,7 @@ class Literal { protected $wanted; - public function __construct(Package $package, $wanted) + public function __construct(PackageInterface $package, $wanted) { $this->package = $package; $this->wanted = $wanted; diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index 38fb838a9..0c58f7b3b 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -13,6 +13,7 @@ namespace Composer\DependencyResolver; use Composer\DependencyResolver\RelationConstraint\RelationConstraintInterface; +use Composer\Repository\RepositoryInterface; /** * A package pool contains repositories that provide packages. @@ -35,13 +36,9 @@ class Pool $this->repositories[] = $repo; foreach ($repo->getPackages() as $package) { - $this->packages[$package->getId()] = $package; + $this->packages[] = $package; foreach ($package->getNames() as $name) { - if (!isset($this->packageByName[$name])) { - $this->packageByNameByName[$name] = array(); - } - $this->packageByName[$name][] = $package; } } diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index 752392eb7..97a840300 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -13,7 +13,7 @@ namespace Composer\Package; use Composer\DependencyResolver\RelationConstraint\RelationConstraintInterface; -use Composer\DependencyResolver\RepositoryInterface; +use Composer\Repository\RepositoryInterface; /** * Base class for packages providing name storage and default match implementation diff --git a/src/Composer/Package/PackageInterface.php b/src/Composer/Package/PackageInterface.php index 4db93316c..213337d29 100644 --- a/src/Composer/Package/PackageInterface.php +++ b/src/Composer/Package/PackageInterface.php @@ -13,7 +13,7 @@ namespace Composer\Package; use Composer\DependencyResolver\RelationConstraint\RelationConstraintInterface; -use Composer\DependencyResolver\RepositoryInterface; +use Composer\Repository\RepositoryInterface; /** * @author Nils Adermann @@ -59,14 +59,14 @@ interface PackageInterface * * @return string The repository type */ - function getRepositoryType(); + function getSourceType(); /** * Returns the repository url of this package, e.g. git://github.com/naderman/composer.git * * @return string The repository url */ - function getRepositoryUrl(); + function getSourceUrl(); /** * Returns the release type of this package, e.g. stable or beta diff --git a/tests/Composer/Test/DependencyResolver/LiteralTest.php b/tests/Composer/Test/DependencyResolver/LiteralTest.php index c7513ff08..a1fcd579d 100644 --- a/tests/Composer/Test/DependencyResolver/LiteralTest.php +++ b/tests/Composer/Test/DependencyResolver/LiteralTest.php @@ -13,7 +13,7 @@ namespace Composer\Test\DependencyResolver; use Composer\DependencyResolver\Literal; -use Composer\DependencyResolver\MemoryPackage; +use Composer\Package\MemoryPackage; class SolvableTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Composer/Test/DependencyResolver/PoolTest.php b/tests/Composer/Test/DependencyResolver/PoolTest.php index feaafff12..a43e78325 100644 --- a/tests/Composer/Test/DependencyResolver/PoolTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolTest.php @@ -13,8 +13,8 @@ namespace Composer\Test\DependencyResolver; use Composer\DependencyResolver\Pool; -use Composer\DependencyResolver\ArrayRepository; -use Composer\DependencyResolver\MemoryPackage; +use Composer\Repository\ArrayRepository; +use Composer\Package\MemoryPackage; class PoolTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Composer/Test/DependencyResolver/RequestTest.php b/tests/Composer/Test/DependencyResolver/RequestTest.php index 5d7ca324a..6bdc59272 100644 --- a/tests/Composer/Test/DependencyResolver/RequestTest.php +++ b/tests/Composer/Test/DependencyResolver/RequestTest.php @@ -14,9 +14,9 @@ namespace Composer\Test\DependencyResolver; use Composer\DependencyResolver\Request; use Composer\DependencyResolver\Pool; -use Composer\DependencyResolver\ArrayRepository; +use Composer\Repository\ArrayRepository; use Composer\DependencyResolver\Literal; -use Composer\DependencyResolver\MemoryPackage; +use Composer\Package\MemoryPackage; class RequestTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Composer/Test/DependencyResolver/PackageTest.php b/tests/Composer/Test/Package/PackageTest.php similarity index 75% rename from tests/Composer/Test/DependencyResolver/PackageTest.php rename to tests/Composer/Test/Package/PackageTest.php index d8f046d30..cc818d396 100644 --- a/tests/Composer/Test/DependencyResolver/PackageTest.php +++ b/tests/Composer/Test/Package/PackageTest.php @@ -10,20 +10,19 @@ * file that was distributed with this source code. */ -namespace Composer\Test\DependencyResolver; +namespace Composer\Test\Package; -use Composer\DependencyResolver\MemoryPackage; +use Composer\Package\MemoryPackage; class PackageTest extends \PHPUnit_Framework_TestCase { public function testPackage() { - $package = new MemoryPackage('foo', '1', 'beta', 21); + $package = new MemoryPackage('foo', '1', 'beta'); $this->assertEquals('foo', $package->getName()); $this->assertEquals('1', $package->getVersion()); $this->assertEquals('beta', $package->getReleaseType()); - $this->assertEquals(21, $package->getId()); $this->assertEquals('foo-beta-1', (string) $package); } diff --git a/tests/Composer/Test/DependencyResolver/ArrayRepositoryTest.php b/tests/Composer/Test/Repository/ArrayRepositoryTest.php similarity index 79% rename from tests/Composer/Test/DependencyResolver/ArrayRepositoryTest.php rename to tests/Composer/Test/Repository/ArrayRepositoryTest.php index b42365755..7c9f64947 100644 --- a/tests/Composer/Test/DependencyResolver/ArrayRepositoryTest.php +++ b/tests/Composer/Test/Repository/ArrayRepositoryTest.php @@ -10,10 +10,10 @@ * file that was distributed with this source code. */ -namespace Composer\Test\DependencyResolver; +namespace Composer\Test\Repository; -use Composer\DependencyResolver\ArrayRepository; -use Composer\DependencyResolver\MemoryPackage; +use Composer\Repository\ArrayRepository; +use Composer\Package\MemoryPackage; class ArrayRepositoryTest extends \PHPUnit_Framework_TestCase {