Treat empty paths in autoloader as ".", fixes #1727
parent
ef65b63288
commit
3ce71466f1
|
@ -483,7 +483,11 @@ FOOTER;
|
|||
$path = $package->getTargetDir() . '/' . $path;
|
||||
}
|
||||
|
||||
$autoloads[$namespace][] = empty($installPath) ? $path : $installPath.'/'.$path;
|
||||
if (empty($installPath)) {
|
||||
$autoloads[$namespace][] = empty($path) ? '.' : $path;
|
||||
} else {
|
||||
$autoloads[$namespace][] = $installPath.'/'.$path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -809,6 +809,57 @@ EOF;
|
|||
$this->assertContains("require \$baseDir . '/../test.php';", file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
}
|
||||
|
||||
public function testEmptyPaths()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Foo' => ''),
|
||||
'classmap' => array(''),
|
||||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/Foo');
|
||||
file_put_contents($this->workingDir.'/Foo/Bar.php', '<?php namespace Foo; class Bar {}');
|
||||
file_put_contents($this->workingDir.'/class.php', '<?php namespace Classmap; class Foo {}');
|
||||
|
||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_15');
|
||||
|
||||
$expectedNamespace = <<<'EOF'
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Foo' => $baseDir . '/',
|
||||
);
|
||||
|
||||
EOF;
|
||||
|
||||
$expectedClassmap = <<<'EOF'
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Classmap\\Foo' => $baseDir . '/class.php',
|
||||
'Foo\\Bar' => $baseDir . '/Foo/Bar.php',
|
||||
);
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
|
||||
$this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php'));
|
||||
}
|
||||
|
||||
private function assertAutoloadFiles($name, $dir, $type = 'namespaces')
|
||||
{
|
||||
$a = __DIR__.'/Fixtures/autoload_'.$name.'.php';
|
||||
|
|
Loading…
Reference in New Issue