1
0
Fork 0

added tests for PearRepository

pull/658/head
Bastian Hofmann 2012-05-06 14:40:47 +02:00
parent 5ceae7fb1f
commit 7501009d74
2 changed files with 130 additions and 7 deletions

View File

@ -74,7 +74,7 @@ class PearRepository extends ArrayRepository
} }
$this->addPackage($loader->load($rev)); $this->addPackage($loader->load($rev));
if ($this->io->isVerbose()) { if ($this->io->isVerbose()) {
$this->io->write('Loaded '.$packageData['name'].' '.$packageData['version']); $this->io->write('Loaded '. $data['name'].' '. $data['version']);
} }
} }
} }
@ -126,7 +126,7 @@ class PearRepository extends ArrayRepository
/** /**
* @param string $categoryLink * @param string $categoryLink
* @throws TransportException * @throws TransportException
* @throws InvalidArgumentException * @throws \InvalidArgumentException
*/ */
private function fetchPearPackages($categoryLink) private function fetchPearPackages($categoryLink)
{ {
@ -212,7 +212,7 @@ class PearRepository extends ArrayRepository
/** /**
* @todo Improve dependencies resolution of pear packages. * @todo Improve dependencies resolution of pear packages.
* @param array $options * @param array $depsOptions
* @return array * @return array
*/ */
private function parseDependenciesOptions(array $depsOptions) private function parseDependenciesOptions(array $depsOptions)
@ -257,7 +257,7 @@ class PearRepository extends ArrayRepository
/** /**
* @param string $deps * @param string $deps
* @return array * @return array
* @throws InvalidArgumentException * @throws \InvalidArgumentException
*/ */
private function parseDependencies($deps) private function parseDependencies($deps)
{ {
@ -284,7 +284,7 @@ class PearRepository extends ArrayRepository
/** /**
* @param string $packagesLink * @param string $packagesLink
* @return void * @return void
* @throws InvalidArgumentException * @throws \InvalidArgumentException
*/ */
private function fetchPear2Packages($packagesLink) private function fetchPear2Packages($packagesLink)
{ {
@ -358,7 +358,7 @@ class PearRepository extends ArrayRepository
/** /**
* @param string $url * @param string $url
* @return DOMDocument * @return \DOMDocument
*/ */
private function requestXml($url) private function requestXml($url)
{ {
@ -367,7 +367,7 @@ class PearRepository extends ArrayRepository
throw new \UnexpectedValueException('The PEAR channel at '.$url.' did not respond.'); throw new \UnexpectedValueException('The PEAR channel at '.$url.' did not respond.');
} }
$dom = new \DOMDocument('1.0', 'UTF-8'); $dom = new \DOMDocument('1.0', 'UTF-8');
$dom->loadXML($content, LIBXML_NOERROR); $dom->loadXML($content);
return $dom; return $dom;
} }

View File

@ -0,0 +1,123 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Repository;
use Composer\Repository\FilesystemRepository;
use Composer\Test\TestCase;
class PearRepositoryTest extends TestCase {
/**
* @var PearRepository
*/
private $repository;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $remoteFilesystem;
/**
* @dataProvider repositoryDataProvider
* @param string $url
* @param array $expectedPackages
*/
public function testRepositoryRead($url, array $expectedPackages) {
$repoConfig = array(
'url' => $url
);
$this->createRepository($repoConfig);
foreach ($expectedPackages as $expectedPackage) {
$this->assertInstanceOf('Composer\Package\PackageInterface',
$this->repository->findPackage($expectedPackage['name'], $expectedPackage['version']),
'Expected package ' . $expectedPackage['name'] . ', version ' . $expectedPackage['version'] .
' not found in pear channel ' . $url
);
}
}
public function repositoryDataProvider() {
return array(
array(
'pear.phpunit.de',
array(
array('name' => 'pear-phpunit/PHPUnit_MockObject', 'version' => '1.1.1'),
array('name' => 'pear-phpunit/PHPUnit', 'version' => '3.6.10'),
)
),
array(
'pear.php.net',
array(
array('name' => 'pear-pear/PEAR', 'version' => '1.9.4'),
)
),
array(
'pear.pdepend.org',
array(
array('name' => 'pear-pdepend/PHP_Depend', 'version' => '1.0.5'),
)
),
array(
'pear.phpmd.org',
array(
array('name' => 'pear-phpmd/PHP_PMD', 'version' => '1.3.3'),
)
),
array(
'pear.doctrine-project.org',
array(
array('name' => 'pear-doctrine/DoctrineORM', 'version' => '2.2.2'),
)
),
array(
'pear.symfony-project.com',
array(
array('name' => 'pear-symfony/YAML', 'version' => '1.0.6'),
)
),
array(
'pear.pirum-project.org',
array(
array('name' => 'pear-pirum/Pirum', 'version' => '1.1.4'),
)
),
array(
'packages.zendframework.com',
array(
array('name' => 'pear-zf2/Zend_Code', 'version' => '2.0.0.0-beta3'),
)
),
);
}
private function createRepository($repoConfig) {
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
->getMock();
$config = new \Composer\Config();
$this->remoteFilesystem = $this->getMockBuilder('Composer\Util\RemoteFilesystem')
->disableOriginalConstructor()
->getMock();
$this->repository = new PearRepository($repoConfig, $ioInterface, $config, null);
}
protected function tearDown() {
$this->repository = null;
$this->remoteFilesystem = null;
}
}