2012-05-06 12:40:47 +00:00
|
|
|
<?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.
|
|
|
|
*/
|
|
|
|
|
2016-10-05 08:45:22 +00:00
|
|
|
namespace Composer\Test\Repository;
|
2012-05-06 12:40:47 +00:00
|
|
|
|
2016-10-05 08:45:22 +00:00
|
|
|
use Composer\Repository\PearRepository;
|
2018-11-12 14:23:32 +00:00
|
|
|
use Composer\Test\TestCase;
|
2012-05-06 12:40:47 +00:00
|
|
|
|
2012-05-06 13:10:13 +00:00
|
|
|
/**
|
2016-02-25 13:10:46 +00:00
|
|
|
* @group legacy
|
2012-05-06 13:10:13 +00:00
|
|
|
*/
|
2012-05-06 12:55:08 +00:00
|
|
|
class PearRepositoryTest extends TestCase
|
|
|
|
{
|
2012-05-06 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* @var PearRepository
|
|
|
|
*/
|
|
|
|
private $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \PHPUnit_Framework_MockObject_MockObject
|
|
|
|
*/
|
2018-11-12 14:34:54 +00:00
|
|
|
private $httpDownloader;
|
2012-05-06 12:40:47 +00:00
|
|
|
|
2012-06-09 05:48:52 +00:00
|
|
|
public function testComposerShouldSetIncludePath()
|
2012-06-06 01:21:52 +00:00
|
|
|
{
|
|
|
|
$url = 'pear.phpmd.org';
|
2013-05-23 19:51:17 +00:00
|
|
|
if (!@file_get_contents('http://'.$url)) {
|
|
|
|
$this->markTestSkipped('Repository '.$url.' appears to be unreachable');
|
|
|
|
}
|
2012-06-06 01:21:52 +00:00
|
|
|
$expectedPackages = array(
|
2012-06-09 05:48:52 +00:00
|
|
|
array('name' => 'pear-pear.phpmd.org/PHP_PMD', 'version' => '1.3.3'),
|
2012-06-06 01:21:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$repoConfig = array(
|
2015-09-28 09:51:14 +00:00
|
|
|
'url' => $url,
|
2012-06-06 01:21:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->createRepository($repoConfig);
|
|
|
|
|
|
|
|
foreach ($expectedPackages as $expectedPackage) {
|
|
|
|
$package = $this->repository->findPackage($expectedPackage['name'], $expectedPackage['version']);
|
2018-07-24 12:32:52 +00:00
|
|
|
$this->assertInstanceOf(
|
|
|
|
'Composer\Package\PackageInterface',
|
2012-06-06 01:21:52 +00:00
|
|
|
$package,
|
|
|
|
'Expected package ' . $expectedPackage['name'] . ', version ' . $expectedPackage['version'] .
|
|
|
|
' not found in pear channel ' . $url
|
|
|
|
);
|
|
|
|
$this->assertSame(array('/'), $package->getIncludePaths());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 12:40:47 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider repositoryDataProvider
|
|
|
|
* @param string $url
|
2012-06-06 01:21:52 +00:00
|
|
|
* @param array $expectedPackages
|
2012-05-06 12:40:47 +00:00
|
|
|
*/
|
2012-05-06 12:55:08 +00:00
|
|
|
public function testRepositoryRead($url, array $expectedPackages)
|
|
|
|
{
|
2012-05-06 12:40:47 +00:00
|
|
|
$repoConfig = array(
|
2015-09-28 09:51:14 +00:00
|
|
|
'url' => $url,
|
2012-05-06 12:40:47 +00:00
|
|
|
);
|
|
|
|
|
2013-05-23 19:51:17 +00:00
|
|
|
if (!@file_get_contents('http://'.$url)) {
|
|
|
|
$this->markTestSkipped('Repository '.$url.' appears to be unreachable');
|
|
|
|
}
|
2012-05-06 12:40:47 +00:00
|
|
|
|
2013-05-23 19:51:17 +00:00
|
|
|
$this->createRepository($repoConfig);
|
2012-05-06 12:40:47 +00:00
|
|
|
foreach ($expectedPackages as $expectedPackage) {
|
2018-07-24 12:32:52 +00:00
|
|
|
$this->assertInstanceOf(
|
|
|
|
'Composer\Package\PackageInterface',
|
2012-05-06 12:40:47 +00:00
|
|
|
$this->repository->findPackage($expectedPackage['name'], $expectedPackage['version']),
|
|
|
|
'Expected package ' . $expectedPackage['name'] . ', version ' . $expectedPackage['version'] .
|
|
|
|
' not found in pear channel ' . $url
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 12:55:08 +00:00
|
|
|
public function repositoryDataProvider()
|
|
|
|
{
|
2012-05-06 12:40:47 +00:00
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
'pear.php.net',
|
|
|
|
array(
|
2012-06-09 05:48:52 +00:00
|
|
|
array('name' => 'pear-pear.php.net/PEAR', 'version' => '1.9.4'),
|
2015-09-28 09:51:14 +00:00
|
|
|
),
|
2012-05-06 12:40:47 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'pear.pdepend.org',
|
|
|
|
array(
|
2012-06-09 05:48:52 +00:00
|
|
|
array('name' => 'pear-pear.pdepend.org/PHP_Depend', 'version' => '1.0.5'),
|
2015-09-28 09:51:14 +00:00
|
|
|
),
|
2012-05-06 12:40:47 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'pear.phpmd.org',
|
|
|
|
array(
|
2012-06-09 05:48:52 +00:00
|
|
|
array('name' => 'pear-pear.phpmd.org/PHP_PMD', 'version' => '1.3.3'),
|
2015-09-28 09:51:14 +00:00
|
|
|
),
|
2012-05-06 12:40:47 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'pear.doctrine-project.org',
|
|
|
|
array(
|
2012-06-09 05:48:52 +00:00
|
|
|
array('name' => 'pear-pear.doctrine-project.org/DoctrineORM', 'version' => '2.2.2'),
|
2015-09-28 09:51:14 +00:00
|
|
|
),
|
2012-05-06 12:40:47 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'pear.symfony-project.com',
|
|
|
|
array(
|
2012-06-09 05:48:52 +00:00
|
|
|
array('name' => 'pear-pear.symfony-project.com/YAML', 'version' => '1.0.6'),
|
2015-09-28 09:51:14 +00:00
|
|
|
),
|
2012-05-06 12:40:47 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'pear.pirum-project.org',
|
|
|
|
array(
|
2012-06-09 05:48:52 +00:00
|
|
|
array('name' => 'pear-pear.pirum-project.org/Pirum', 'version' => '1.1.4'),
|
2015-09-28 09:51:14 +00:00
|
|
|
),
|
2012-05-06 12:40:47 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-05-06 12:55:08 +00:00
|
|
|
private function createRepository($repoConfig)
|
|
|
|
{
|
2012-05-06 12:40:47 +00:00
|
|
|
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
$config = new \Composer\Config();
|
|
|
|
|
2018-10-31 11:44:54 +00:00
|
|
|
$this->httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')
|
2012-05-06 12:40:47 +00:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
$this->repository = new PearRepository($repoConfig, $ioInterface, $config, null);
|
|
|
|
}
|
|
|
|
|
2012-05-06 12:55:08 +00:00
|
|
|
protected function tearDown()
|
|
|
|
{
|
2012-05-06 12:40:47 +00:00
|
|
|
$this->repository = null;
|
2018-10-31 11:44:54 +00:00
|
|
|
$this->httpDownloader = null;
|
2012-05-06 12:40:47 +00:00
|
|
|
}
|
2012-06-06 01:21:52 +00:00
|
|
|
}
|