1
0
Fork 0

Merge pull request #1029 from stof/autoload_notice

Removed a PHP notice when dumping the autoloader
pull/1031/head
Jordi Boggiano 2012-08-25 09:36:13 -07:00
commit 5755158e5b
2 changed files with 23 additions and 1 deletions

View File

@ -85,7 +85,7 @@ EOF;
// add custom psr-0 autoloading if the root package has a target dir
$targetDirLoader = null;
$mainAutoload = $mainPackage->getAutoload();
if ($mainPackage->getTargetDir() && $mainAutoload['psr-0']) {
if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
$levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/')));
$prefixes = implode(', ', array_map(function ($prefix) {
return var_export($prefix, true);

View File

@ -164,6 +164,28 @@ class AutoloadGeneratorTest extends TestCase
$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()
{
$package = new Package('a', '1.0', '1.0');