Fix optimized autoloader generation for PSR-0 configs that include non-existent dirs, fixes #1286
parent
ead17b2680
commit
c5f3a6febd
|
@ -126,6 +126,9 @@ EOF;
|
||||||
preg_quote(rtrim($dir, '/')),
|
preg_quote(rtrim($dir, '/')),
|
||||||
strpos($namespace, '_') === false ? preg_quote(strtr($namespace, '\\', '/')) : ''
|
strpos($namespace, '_') === false ? preg_quote(strtr($namespace, '\\', '/')) : ''
|
||||||
);
|
);
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach (ClassMapGenerator::createMap($dir, $whitelist) as $class => $path) {
|
foreach (ClassMapGenerator::createMap($dir, $whitelist) as $class => $path) {
|
||||||
if ('' === $namespace || 0 === strpos($class, $namespace)) {
|
if ('' === $namespace || 0 === strpos($class, $namespace)) {
|
||||||
$path = '/'.$filesystem->findShortestPath(getcwd(), $path, true);
|
$path = '/'.$filesystem->findShortestPath(getcwd(), $path, true);
|
||||||
|
|
|
@ -212,6 +212,24 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated, even if empty.");
|
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated, even if empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPSR0ToClassMapIgnoresNonExistingDir()
|
||||||
|
{
|
||||||
|
$package = new Package('a', '1.0', '1.0');
|
||||||
|
|
||||||
|
$package->setAutoload(array('psr-0' => array('foo/bar/non/existing/')));
|
||||||
|
|
||||||
|
$this->repository->expects($this->once())
|
||||||
|
->method('getPackages')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
|
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8');
|
||||||
|
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
|
||||||
|
$this->assertEquals(
|
||||||
|
array(),
|
||||||
|
include $this->vendorDir.'/composer/autoload_classmap.php'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testVendorsClassMapAutoloading()
|
public function testVendorsClassMapAutoloading()
|
||||||
{
|
{
|
||||||
$package = new Package('a', '1.0', '1.0');
|
$package = new Package('a', '1.0', '1.0');
|
||||||
|
|
Loading…
Reference in New Issue