Fix ComposerRepo issue
parent
f91859ceff
commit
40f5806a7c
|
@ -242,11 +242,15 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
return array_values($this->loadAsyncPackages($packageMap));
|
return array_values($this->loadAsyncPackages($packageMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \LogicException('Composer repositories that have lazy providers and no available-packages list can not load the complete list of packages, use getProviderNames instead.');
|
if ($this->hasPartialPackages()) {
|
||||||
|
return array_values($this->partialPackagesByName);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \LogicException('Composer repositories that have lazy providers and no available-packages list can not load the complete list of packages, use getPackageNames instead.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hasProviders) {
|
if ($hasProviders) {
|
||||||
throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getProviderNames instead.');
|
throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getPackages();
|
return parent::getPackages();
|
||||||
|
@ -263,6 +267,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO implement new list API endpoint for those repos somehow?
|
// TODO implement new list API endpoint for those repos somehow?
|
||||||
|
|
||||||
|
if ($this->hasPartialPackages()) {
|
||||||
|
return array_keys($this->partialPackagesByName);
|
||||||
|
}
|
||||||
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,14 +400,6 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
$this->loadProviderListings($this->loadRootServerFile());
|
$this->loadProviderListings($this->loadRootServerFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasPartialPackages) {
|
|
||||||
if (null === $this->partialPackagesByName) {
|
|
||||||
$this->initializePartialPackages();
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_keys($this->partialPackagesByName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->lazyProvidersUrl) {
|
if ($this->lazyProvidersUrl) {
|
||||||
// Can not determine list of provided packages for lazy repositories
|
// Can not determine list of provided packages for lazy repositories
|
||||||
return array();
|
return array();
|
||||||
|
|
|
@ -286,30 +286,28 @@ class ComposerRepositoryTest extends TestCase
|
||||||
|
|
||||||
public function testGetProviderNamesWillReturnPartialPackageNames()
|
public function testGetProviderNamesWillReturnPartialPackageNames()
|
||||||
{
|
{
|
||||||
$rfs = $this->getMockBuilder('Composer\Util\RemoteFilesystem')
|
$httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$rfs->expects($this->at(0))
|
$httpDownloader->expects($this->at(0))
|
||||||
->method('getContents')
|
->method('get')
|
||||||
->with('example.org', 'http://example.org/packages.json', false)
|
->with($url = 'http://example.org/packages.json')
|
||||||
->willReturn(json_encode(array(
|
->willReturn(new \Composer\Util\Http\Response(array('url' => $url), 200, array(), json_encode(array(
|
||||||
'providers-lazy-url' => '/foo/p/%package%.json',
|
'providers-lazy-url' => '/foo/p/%package%.json',
|
||||||
'packages' => array('foo/bar' => array(
|
'packages' => array('foo/bar' => array(
|
||||||
'dev-branch' => array(),
|
'dev-branch' => array('name' => 'foo/bar'),
|
||||||
'v1.0.0' => array(),
|
'v1.0.0' => array('name' => 'foo/bar'),
|
||||||
))
|
))
|
||||||
)));
|
))));
|
||||||
|
|
||||||
$repository = new ComposerRepository(
|
$repository = new ComposerRepository(
|
||||||
array('url' => 'http://example.org/packages.json'),
|
array('url' => 'http://example.org/packages.json'),
|
||||||
new NullIO(),
|
new NullIO(),
|
||||||
FactoryMock::createConfig(),
|
FactoryMock::createConfig(),
|
||||||
null,
|
$httpDownloader
|
||||||
$rfs
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertTrue($repository->hasProviders());
|
$this->assertEquals(array('foo/bar'), $repository->getPackageNames());
|
||||||
$this->assertEquals(array('foo/bar'), $repository->getProviderNames());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue