1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Add PEAR channel reader & Update PearRepository to use it.

This commit is contained in:
Alexey Prilipko 2012-06-09 16:48:52 +11:00
parent ee2834a169
commit e173f11b37
29 changed files with 1970 additions and 342 deletions

View file

@ -13,6 +13,7 @@
namespace Composer\Test\Mock;
use Composer\Util\RemoteFilesystem;
use Composer\Downloader\TransportException;
/**
* Remote filesystem mock
@ -29,10 +30,11 @@ class RemoteFilesystemMock extends RemoteFilesystem
public function getContents($originUrl, $fileUrl, $progress = true)
{
if(!empty($this->contentMap[$fileUrl]))
if (!empty($this->contentMap[$fileUrl])) {
return $this->contentMap[$fileUrl];
}
throw new \Composer\Downloader\TransportException('The "'.$fileUrl.'" file could not be downloaded (NOT FOUND)', 404);
throw new TransportException('The "'.$fileUrl.'" file could not be downloaded (NOT FOUND)', 404);
}
}

View file

@ -0,0 +1,144 @@
<?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\Pear;
use Composer\Test\TestCase;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Package\Link;
use Composer\Package\MemoryPackage;
use Composer\Test\Mock\RemoteFilesystemMock;
class ChannelReaderTest extends TestCase
{
public function testShouldBuildPackagesFromPearSchema()
{
$rfs = new RemoteFilesystemMock(array(
'http://pear.net/channel.xml' => file_get_contents(__DIR__ . '/Fixtures/channel.1.1.xml'),
'http://test.loc/rest11/c/categories.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.1/categories.xml'),
'http://test.loc/rest11/c/Default/packagesinfo.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.1/packagesinfo.xml'),
));
$reader = new \Composer\Repository\Pear\ChannelReader($rfs);
$channelInfo = $reader->read('http://pear.net/');
$packages = $channelInfo->getPackages();
$this->assertCount(3, $packages);
$this->assertEquals('HTTP_Client', $packages[0]->getPackageName());
$this->assertEquals('HTTP_Request', $packages[1]->getPackageName());
$this->assertEquals('MDB2', $packages[2]->getPackageName());
$mdb2releases = $packages[2]->getReleases();
$this->assertEquals(9, count($mdb2releases['2.4.0']->getDependencyInfo()->getOptionals()));
}
public function testShouldSelectCorrectReader()
{
$rfs = new RemoteFilesystemMock(array(
'http://pear.1.0.net/channel.xml' => file_get_contents(__DIR__ . '/Fixtures/channel.1.0.xml'),
'http://test.loc/rest10/p/packages.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/packages.xml'),
'http://test.loc/rest10/p/http_client/info.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_client_info.xml'),
'http://test.loc/rest10/p/http_request/info.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_request_info.xml'),
'http://pear.1.1.net/channel.xml' => file_get_contents(__DIR__ . '/Fixtures/channel.1.1.xml'),
'http://test.loc/rest11/c/categories.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.1/categories.xml'),
'http://test.loc/rest11/c/Default/packagesinfo.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.1/packagesinfo.xml'),
));
$reader = new \Composer\Repository\Pear\ChannelReader($rfs);
$reader->read('http://pear.1.0.net/');
$reader->read('http://pear.1.1.net/');
}
public function testShouldCreatePackages()
{
$reader = $this->getMockBuilder('\Composer\Repository\Pear\ChannelReader')
->disableOriginalConstructor()
->getMock();
$ref = new \ReflectionMethod($reader, 'buildComposerPackages');
$ref->setAccessible(true);
$packageInfo = new PackageInfo(
'test.loc',
'sample',
'license',
'shortDescription',
'description',
array(
'1.0.0.1' => new ReleaseInfo(
'stable',
new DependencyInfo(
array(
new DependencyConstraint(
'required',
'> 5.2.0.0',
'php',
''
),
new DependencyConstraint(
'conflicts',
'== 2.5.6.0',
'pear.php.net',
'broken'
),
),
array(
'*' => array(
new DependencyConstraint(
'optional',
'*',
'ext',
'xml'
),
)
)
)
)
)
);
$packages = $ref->invoke($reader, 'test.loc', 'test', array($packageInfo));
$expectedPackage = new MemoryPackage('pear-test.loc/sample', '1.0.0.1' , '1.0.0.1');
$expectedPackage->setType('library');
$expectedPackage->setDistType('pear');
$expectedPackage->setDescription('description');
$expectedPackage->setDistUrl("http://test.loc/get/sample-1.0.0.1.tgz");
$expectedPackage->setAutoload(array('classmap' => array('')));
$expectedPackage->setIncludePaths(array('/'));
$expectedPackage->setRequires(array(
new Link('pear-test.loc/sample', 'php', $this->createConstraint('>', '5.2.0.0'), 'required', '> 5.2.0.0'),
));
$expectedPackage->setConflicts(array(
new Link('pear-test.loc/sample', 'pear-pear.php.net/broken', $this->createConstraint('==', '2.5.6.0'), 'conflicts', '== 2.5.6.0'),
));
$expectedPackage->setSuggests(array(
'*-ext-xml' => '*',
));
$expectedPackage->setReplaces(array(
new Link('pear-test.loc/sample', 'pear-test/sample', new VersionConstraint('==', '1.0.0.1'), 'replaces', '== 1.0.0.1'),
));
$this->assertCount(1, $packages);
$this->assertEquals($expectedPackage, $packages[0], 0, 1);
}
private function createConstraint($operator, $version)
{
$constraint = new VersionConstraint($operator, $version);
$constraint->setPrettyString($operator.' '.$version);
return $constraint;
}
}

View file

@ -0,0 +1,41 @@
<?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\Pear;
use Composer\Test\TestCase;
use Composer\Test\Mock\RemoteFilesystemMock;
class ChannelRest10ReaderTest extends TestCase
{
public function testShouldBuildPackagesFromPearSchema()
{
$rfs = new RemoteFilesystemMock(array(
'http://test.loc/rest10/p/packages.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/packages.xml'),
'http://test.loc/rest10/p/http_client/info.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_client_info.xml'),
'http://test.loc/rest10/r/http_client/allreleases.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_client_allreleases.xml'),
'http://test.loc/rest10/r/http_client/deps.1.2.1.txt' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_client_deps.1.2.1.txt'),
'http://test.loc/rest10/p/http_request/info.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_request_info.xml'),
'http://test.loc/rest10/r/http_request/allreleases.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_request_allreleases.xml'),
'http://test.loc/rest10/r/http_request/deps.1.4.0.txt' => file_get_contents(__DIR__ . '/Fixtures/Rest1.0/http_request_deps.1.4.0.txt'),
));
$reader = new \Composer\Repository\Pear\ChannelRest10Reader($rfs);
/** @var $packages \Composer\Package\PackageInterface[] */
$packages = $reader->read('http://test.loc/rest10');
$this->assertCount(2, $packages);
$this->assertEquals('HTTP_Client', $packages[0]->getPackageName());
$this->assertEquals('HTTP_Request', $packages[1]->getPackageName());
}
}

View file

@ -0,0 +1,37 @@
<?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\Pear;
use Composer\Test\TestCase;
use Composer\Test\Mock\RemoteFilesystemMock;
class ChannelRest11ReaderTest extends TestCase
{
public function testShouldBuildPackagesFromPearSchema()
{
$rfs = new RemoteFilesystemMock(array(
'http://pear.1.1.net/channel.xml' => file_get_contents(__DIR__ . '/Fixtures/channel.1.1.xml'),
'http://test.loc/rest11/c/categories.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.1/categories.xml'),
'http://test.loc/rest11/c/Default/packagesinfo.xml' => file_get_contents(__DIR__ . '/Fixtures/Rest1.1/packagesinfo.xml'),
));
$reader = new \Composer\Repository\Pear\ChannelRest11Reader($rfs);
/** @var $packages \Composer\Package\PackageInterface[] */
$packages = $reader->read('http://test.loc/rest11');
$this->assertCount(3, $packages);
$this->assertEquals('HTTP_Client', $packages[0]->getPackageName());
$this->assertEquals('HTTP_Request', $packages[1]->getPackageName());
}
}

View file

@ -0,0 +1,167 @@
[
{
"expected": [
{
"type" : "required",
"constraint" : "*",
"channel" : "pear.php.net",
"name" : "Foo"
}
],
"1.0": [
{ "type": "pkg", "rel": "has", "name": "Foo" }
],
"2.0": {
"required": {
"package": {
"name": "Foo",
"channel": "pear.php.net"
}
}
}
},
{
"expected": [
{
"type" : "required",
"constraint" : ">1.0.0.0",
"channel" : "pear.php.net",
"name" : "Foo"
}
],
"1.0": [
{ "type": "pkg", "rel": "gt", "version": "1.0.0", "name": "Foo" }
],
"2.0": {
"required": {
"package": {
"name": "Foo",
"channel": "pear.php.net",
"min": "1.0.0",
"exclude": "1.0.0"
}
}
}
},
{
"expected": [
{
"type" : "conflicts",
"constraint" : "*",
"channel" : "pear.php.net",
"name" : "Foo"
}
],
"1.0": [
{ "type": "pkg", "rel": "not", "name": "Foo" }
],
"2.0": {
"required": {
"package": {
"name": "Foo",
"channel": "pear.php.net",
"conflicts": true
}
}
}
},
{
"expected": [
{
"type" : "required",
"constraint" : ">=1.0.0.0",
"channel" : "pear.php.net",
"name" : "Foo"
},
{
"type" : "required",
"constraint" : "<2.0.0.0",
"channel" : "pear.php.net",
"name" : "Foo"
}
],
"1.0": [
{ "type": "pkg", "rel": "ge", "version": "1.0.0", "name": "Foo" },
{ "type": "pkg", "rel": "lt", "version": "2.0.0", "name": "Foo" }
],
"2.0": {
"required": {
"package": [
{
"name": "Foo",
"channel": "pear.php.net",
"min": "1.0.0"
},
{
"name": "Foo",
"channel": "pear.php.net",
"max": "2.0.0",
"exclude": "2.0.0"
}
]
}
}
},
{
"expected": [
{
"type" : "required",
"constraint" : ">=5.3.0.0",
"channel" : "php",
"name" : ""
}
],
"1.0": [
{ "type": "php", "rel": "ge", "version": "5.3"}
],
"2.0": {
"required": {
"php": {
"min": "5.3"
}
}
}
},
{
"expected": [
{
"type" : "required",
"constraint" : "*",
"channel" : "ext",
"name" : "xmllib"
}
],
"1.0": [
{ "type": "ext", "rel": "has", "name": "xmllib"}
],
"2.0": {
"required": {
"extension": [
{
"name": "xmllib"
}
]
}
}
},
{
"expected": [
{
"type" : "optional",
"constraint" : "*",
"channel" : "ext",
"name" : "xmllib"
}
],
"1.0": false,
"2.0": {
"optional": {
"extension": [
{
"name": "xmllib"
}
]
}
}
}
]

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<a xmlns="http://pear.php.net/dtd/rest.allreleases" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases http://pear.php.net/dtd/rest.allreleases.xsd">
<p>HTTP_Client</p>
<c>pear.net</c>
<r>
<v>1.2.1</v>
<s>stable</s>
</r>
</a>

View file

@ -0,0 +1 @@
a:1:{s:8:"required";a:3:{s:3:"php";a:1:{s:3:"min";s:5:"4.3.0";}s:13:"pearinstaller";a:1:{s:3:"min";s:5:"1.4.3";}s:7:"package";a:3:{s:4:"name";s:12:"HTTP_Request";s:7:"channel";s:8:"pear.net";s:3:"min";s:5:"1.4.0";}}}

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<p xmlns="http://pear.php.net/dtd/rest.package" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.package http://pear.php.net/dtd/rest.package.xsd">
<n>HTTP_Client</n>
<c>pear.net</c>
<ca xlink:href="/rest/c/Default">Default</ca>
<l>BSD</l>
<s>
Easy way to perform multiple HTTP requests and process their results
</s>
<d>
The HTTP_Client class wraps around HTTP_Request and provides a higher level interface for performing multiple HTTP requests. Features: * Manages cookies and referrers between requests * Handles HTTP redirection * Has methods to set default headers and request parameters * Implements the Subject-Observer design pattern: the base class sends events to listeners that do the response processing.
</d>
<r xlink:href="/rest/r/http_client"/>
</p>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<a xmlns="http://pear.php.net/dtd/rest.allreleases" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.allreleases http://pear.php.net/dtd/rest.allreleases.xsd">
<p>HTTP_Request</p>
<c>pear.net</c>
<r>
<v>1.4.0</v>
<s>stable</s>
</r>
</a>

View file

@ -0,0 +1 @@
a:1:{s:8:"required";a:3:{s:3:"php";a:1:{s:3:"min";s:5:"4.0.0";}s:13:"pearinstaller";a:1:{s:3:"min";s:7:"1.4.0b1";}s:7:"package";a:2:{i:0;a:3:{s:4:"name";s:7:"Net_URL";s:7:"channel";s:12:"pear.dev.loc";s:3:"min";s:6:"1.0.12";}i:1;a:3:{s:4:"name";s:10:"Net_Socket";s:7:"channel";s:8:"pear.net";s:3:"min";s:5:"1.0.2";}}}}

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<p xmlns="http://pear.php.net/dtd/rest.package" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.package http://pear.php.net/dtd/rest.package.xsd">
<n>HTTP_Request</n>
<c>pear.net</c>
<ca xlink:href="/rest/c/Default">Default</ca>
<l>BSD</l>
<s>Provides an easy way to perform HTTP requests</s>
<d>
Supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc.
</d>
<r xlink:href="/rest/r/http_request"/>
</p>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<a xmlns="http://pear.php.net/dtd/rest.allpackages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.allpackages http://pear.php.net/dtd/rest.allpackages.xsd">
<c>pear.net</c>
<p>HTTP_Client</p>
<p>HTTP_Request</p>
</a>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<a xmlns="http://pear.php.net/dtd/rest.allcategories" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.allcategories http://pear.php.net/dtd/rest.allcategories.xsd">
<ch>pear.net</ch>
<c xlink:href="/rest/c/Default/info.xml">Default</c>
</a>

View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<f xmlns="http://pear.php.net/dtd/rest.categorypackageinfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.categorypackageinfo http://pear.php.net/dtd/rest.categorypackageinfo.xsd">
<pi>
<p>
<n>HTTP_Client</n>
<c>pear.net</c>
<ca xlink:href="/rest/c/Default">Default</ca>
<l>BSD</l>
<s>
Easy way to perform multiple HTTP requests and process their results
</s>
<d>
The HTTP_Client class wraps around HTTP_Request and provides a higher level interface for performing multiple HTTP requests. Features: * Manages cookies and referrers between requests * Handles HTTP redirection * Has methods to set default headers and request parameters * Implements the Subject-Observer design pattern: the base class sends events to listeners that do the response processing.
</d>
<r xlink:href="/rest/r/http_client"/>
</p>
<a>
<r>
<v>1.2.1</v>
<s>stable</s>
</r>
</a>
<deps>
<v>1.2.1</v>
<d>a:1:{s:8:"required";a:3:{s:3:"php";a:1:{s:3:"min";s:5:"4.3.0";}s:13:"pearinstaller";a:1:{s:3:"min";s:5:"1.4.3";}s:7:"package";a:3:{s:4:"name";s:12:"HTTP_Request";s:7:"channel";s:8:"pear.net";s:3:"min";s:5:"1.4.0";}}}</d>
</deps>
</pi>
<pi>
<p>
<n>HTTP_Request</n>
<c>pear.net</c>
<ca xlink:href="/rest/c/Default">Default</ca>
<l>BSD</l>
<s>Provides an easy way to perform HTTP requests</s>
<d>
Supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc.
</d>
<r xlink:href="/rest/r/http_request"/>
</p>
<a>
<r>
<v>1.4.0</v>
<s>stable</s>
</r>
</a>
<deps>
<v>1.4.0</v>
<d>a:1:{s:8:&quot;required&quot;;a:3:{s:3:&quot;php&quot;;a:1:{s:3:&quot;min&quot;;s:5:&quot;4.0.0&quot;;}s:13:&quot;pearinstaller&quot;;a:1:{s:3:&quot;min&quot;;s:7:&quot;1.4.0b1&quot;;}s:7:&quot;package&quot;;a:2:{i:0;a:3:{s:4:&quot;name&quot;;s:7:&quot;Net_URL&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:6:&quot;1.0.12&quot;;}i:1;a:3:{s:4:&quot;name&quot;;s:10:&quot;Net_Socket&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.0.2&quot;;}}}}</d>
</deps>
</pi>
<pi>
<p><n>MDB2</n>
<c>pear.net</c>
<ca xlink:href="/rest/c/Database">Database</ca>
<l>BSD License</l>
<s>database abstraction layer</s>
<d>PEAR MDB2 is a merge of the PEAR DB and Metabase php database abstraction layers.
It provides a common API for all supported RDBMS. The main difference to most
other DB abstraction packages is that MDB2 goes much further to ensure
portability. MDB2 provides most of its many features optionally that
can be used to construct portable SQL statements:
* Object-Oriented API
* A DSN (data source name) or array format for specifying database servers
* Datatype abstraction and on demand datatype conversion
* Various optional fetch modes to fix portability issues
* Portable error codes
* Sequential and non sequential row fetching as well as bulk fetching
* Ability to make buffered and unbuffered queries
* Ordered array and associative array for the fetched rows
* Prepare/execute (bind) named and unnamed placeholder emulation
* Sequence/autoincrement emulation
* Replace emulation
* Limited sub select emulation
* Row limit emulation
* Transactions/savepoint support
* Large Object support
* Index/Unique Key/Primary Key support
* Pattern matching abstraction
* Module framework to load advanced functionality on demand
* Ability to read the information schema
* RDBMS management methods (creating, dropping, altering)
* Reverse engineering schemas from an existing database
* SQL function call abstraction
* Full integration into the PEAR Framework
* PHPDoc API documentation</d>
<r xlink:href="/rest/r/mdb2"/>
</p>
<a>
<r><v>2.4.0</v><s>stable</s></r>
</a>
<deps>
<v>2.4.0</v>
<d>a:2:{s:8:&quot;required&quot;;a:3:{s:3:&quot;php&quot;;a:1:{s:3:&quot;min&quot;;s:5:&quot;4.3.2&quot;;}s:13:&quot;pearinstaller&quot;;a:1:{s:3:&quot;min&quot;;s:7:&quot;1.4.0b1&quot;;}s:7:&quot;package&quot;;a:3:{s:4:&quot;name&quot;;s:4:&quot;PEAR&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.3.6&quot;;}}s:5:&quot;group&quot;;a:9:{i:0;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:29:&quot;Frontbase SQL driver for MDB2&quot;;s:4:&quot;name&quot;;s:5:&quot;fbsql&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:17:&quot;MDB2_Driver_fbsql&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;0.3.0&quot;;}}i:1;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:34:&quot;Interbase/Firebird driver for MDB2&quot;;s:4:&quot;name&quot;;s:5:&quot;ibase&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:17:&quot;MDB2_Driver_ibase&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.4.0&quot;;}}i:2;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:21:&quot;MySQL driver for MDB2&quot;;s:4:&quot;name&quot;;s:5:&quot;mysql&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:17:&quot;MDB2_Driver_mysql&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.4.0&quot;;}}i:3;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:22:&quot;MySQLi driver for MDB2&quot;;s:4:&quot;name&quot;;s:6:&quot;mysqli&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:18:&quot;MDB2_Driver_mysqli&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.4.0&quot;;}}i:4;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:29:&quot;MS SQL Server driver for MDB2&quot;;s:4:&quot;name&quot;;s:5:&quot;mssql&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:17:&quot;MDB2_Driver_mssql&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.2.0&quot;;}}i:5;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:22:&quot;Oracle driver for MDB2&quot;;s:4:&quot;name&quot;;s:4:&quot;oci8&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:16:&quot;MDB2_Driver_oci8&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.4.0&quot;;}}i:6;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:26:&quot;PostgreSQL driver for MDB2&quot;;s:4:&quot;name&quot;;s:5:&quot;pgsql&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:17:&quot;MDB2_Driver_pgsql&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.4.0&quot;;}}i:7;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:24:&quot;Querysim driver for MDB2&quot;;s:4:&quot;name&quot;;s:8:&quot;querysim&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:20:&quot;MDB2_Driver_querysim&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;0.6.0&quot;;}}i:8;a:2:{s:7:&quot;attribs&quot;;a:2:{s:4:&quot;hint&quot;;s:23:&quot;SQLite2 driver for MDB2&quot;;s:4:&quot;name&quot;;s:6:&quot;sqlite&quot;;}s:10:&quot;subpackage&quot;;a:3:{s:4:&quot;name&quot;;s:18:&quot;MDB2_Driver_sqlite&quot;;s:7:&quot;channel&quot;;s:12:&quot;pear.php.net&quot;;s:3:&quot;min&quot;;s:5:&quot;1.4.0&quot;;}}}}</d>
</deps>
</pi>
</f>

View file

@ -0,0 +1,12 @@
<channel xmlns="http://pear.php.net/channel-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://pear.php.net/channel-1.0 http://pear.php.net/dtd/channel-1.0.xsd">
<name>pear.net</name>
<summary>Test PEAR channel</summary>
<suggestedalias>test_alias</suggestedalias>
<servers>
<primary>
<rest>
<baseurl type="REST1.0">http://test.loc/rest10/</baseurl>
</rest>
</primary>
</servers>
</channel>

View file

@ -0,0 +1,12 @@
<channel xmlns="http://pear.php.net/channel-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://pear.php.net/channel-1.0 http://pear.php.net/dtd/channel-1.0.xsd">
<name>pear.net</name>
<summary>Test PEAR channel</summary>
<suggestedalias>test_alias</suggestedalias>
<servers>
<primary>
<rest>
<baseurl type="REST1.1">http://test.loc/rest11/</baseurl>
</rest>
</primary>
</servers>
</channel>

View file

@ -0,0 +1,58 @@
<?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\Pear;
use Composer\Test\TestCase;
class PackageDependencyParserTest extends TestCase
{
/**
* @dataProvider dataProvider10
* @param $expected
* @param $data
*/
public function testShouldParseDependencies($expected, $data10, $data20)
{
$expectedDependencies = array();
foreach ($expected as $expectedItem) {
$expectedDependencies[] = new DependencyConstraint(
$expectedItem['type'],
$expectedItem['constraint'],
$expectedItem['channel'],
$expectedItem['name']
);
}
$parser = new PackageDependencyParser();
if (false !== $data10) {
$result = $parser->buildDependencyInfo($data10);
$this->assertEquals($expectedDependencies, $result->getRequires() + $result->getOptionals(), "Failed for package.xml 1.0 format");
}
if (false !== $data20) {
$result = $parser->buildDependencyInfo($data20);
$this->assertEquals($expectedDependencies, $result->getRequires() + $result->getOptionals(), "Failed for package.xml 2.0 format");
}
}
public function dataProvider10()
{
$data = json_decode(file_get_contents(__DIR__.'/Fixtures/DependencyParserTestData.json'), true);
if (0 !== json_last_error()) {
throw new \PHPUnit_Framework_Exception('Invalid json file.');
}
return $data;
}
}

View file

@ -29,11 +29,11 @@ class PearRepositoryTest extends TestCase
*/
private $remoteFilesystem;
public function testComposerNonCompatibleRepositoryShouldSetIncludePath()
public function testComposerShouldSetIncludePath()
{
$url = 'pear.phpmd.org';
$expectedPackages = array(
array('name' => 'pear-phpmd/PHP_PMD', 'version' => '1.3.3'),
array('name' => 'pear-pear.phpmd.org/PHP_PMD', 'version' => '1.3.3'),
);
$repoConfig = array(
@ -78,53 +78,47 @@ class PearRepositoryTest extends TestCase
public function repositoryDataProvider()
{
return array(
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('name' => 'pear-pear.phpunit.de/PHPUnit_MockObject', 'version' => '1.1.1'),
array('name' => 'pear-pear.phpunit.de/PHPUnit', 'version' => '3.6.10'),
)
),
array(
'pear.php.net',
array(
array('name' => 'pear-pear/PEAR', 'version' => '1.9.4'),
array('name' => 'pear-pear.php.net/PEAR', 'version' => '1.9.4'),
)
),
array(
'pear.pdepend.org',
array(
array('name' => 'pear-pdepend/PHP_Depend', 'version' => '1.0.5'),
array('name' => 'pear-pear.pdepend.org/PHP_Depend', 'version' => '1.0.5'),
)
),
array(
'pear.phpmd.org',
array(
array('name' => 'pear-phpmd/PHP_PMD', 'version' => '1.3.3'),
array('name' => 'pear-pear.phpmd.org/PHP_PMD', 'version' => '1.3.3'),
)
),
array(
'pear.doctrine-project.org',
array(
array('name' => 'pear-doctrine/DoctrineORM', 'version' => '2.2.2'),
array('name' => 'pear-pear.doctrine-project.org/DoctrineORM', 'version' => '2.2.2'),
)
),
array(
'pear.symfony-project.com',
array(
array('name' => 'pear-symfony/YAML', 'version' => '1.0.6'),
array('name' => 'pear-pear.symfony-project.com/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'),
array('name' => 'pear-pear.pirum-project.org/Pirum', 'version' => '1.1.4'),
)
),
);