Merge pull request #1029 from stof/autoload_notice
Removed a PHP notice when dumping the autoloaderpull/1031/head
commit
5755158e5b
|
@ -85,7 +85,7 @@ EOF;
|
||||||
// add custom psr-0 autoloading if the root package has a target dir
|
// add custom psr-0 autoloading if the root package has a target dir
|
||||||
$targetDirLoader = null;
|
$targetDirLoader = null;
|
||||||
$mainAutoload = $mainPackage->getAutoload();
|
$mainAutoload = $mainPackage->getAutoload();
|
||||||
if ($mainPackage->getTargetDir() && $mainAutoload['psr-0']) {
|
if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
|
||||||
$levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/')));
|
$levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/')));
|
||||||
$prefixes = implode(', ', array_map(function ($prefix) {
|
$prefixes = implode(', ', array_map(function ($prefix) {
|
||||||
return var_export($prefix, true);
|
return var_export($prefix, true);
|
||||||
|
|
|
@ -164,6 +164,28 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
$this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_target_dir.php', $this->vendorDir.'/composer/autoload_realTargetDir.php');
|
$this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_target_dir.php', $this->vendorDir.'/composer/autoload_realTargetDir.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMainPackageAutoloadingWithTargetDirAndNoPsr()
|
||||||
|
{
|
||||||
|
$package = new Package('a', '1.0', '1.0');
|
||||||
|
$package->setAutoload(array(
|
||||||
|
'classmap' => array('composersrc/'),
|
||||||
|
));
|
||||||
|
$package->setTargetDir('Main/Foo/');
|
||||||
|
|
||||||
|
$this->repository->expects($this->once())
|
||||||
|
->method('getPackages')
|
||||||
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
|
$this->vendorDir .= '/subdir';
|
||||||
|
|
||||||
|
$this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
|
||||||
|
$this->fs->ensureDirectoryExists($this->workingDir.'/src');
|
||||||
|
|
||||||
|
$this->createClassFile($this->workingDir);
|
||||||
|
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDirNoPsr');
|
||||||
|
$this->assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap');
|
||||||
|
}
|
||||||
|
|
||||||
public function testVendorsAutoloading()
|
public function testVendorsAutoloading()
|
||||||
{
|
{
|
||||||
$package = new Package('a', '1.0', '1.0');
|
$package = new Package('a', '1.0', '1.0');
|
||||||
|
|
Loading…
Reference in New Issue