Fix PSR-4 autoload classmap generator
parent
e060adeb97
commit
01cd990995
|
@ -168,7 +168,7 @@ EOF;
|
|||
$whitelist = sprintf(
|
||||
'{%s/%s.+(?<!(?<!/)Test\.php)$}',
|
||||
preg_quote($dir),
|
||||
($psrType === 'psr-4' || strpos($namespace, '_') === false) ? preg_quote(strtr($namespace, '\\', '/')) : ''
|
||||
($psrType === 'psr-0' && strpos($namespace, '_') === false) ? preg_quote(strtr($namespace, '\\', '/')) : ''
|
||||
);
|
||||
foreach (ClassMapGenerator::createMap($dir, $whitelist) as $class => $path) {
|
||||
if ('' === $namespace || 0 === strpos($class, $namespace)) {
|
||||
|
|
|
@ -111,17 +111,19 @@ class AutoloadGeneratorTest extends TestCase
|
|||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/composer');
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/src');
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/src/Lala');
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/lib');
|
||||
file_put_contents($this->workingDir.'/src/Lala/ClassMapMain.php', '<?php namespace Lala; class ClassMapMain {}');
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/src-fruit');
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/src-cake');
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/lib-cake');
|
||||
file_put_contents($this->workingDir.'/src-cake/ClassMapBar.php', '<?php namespace Acme\Cake; class ClassMapBar {}');
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/composersrc');
|
||||
file_put_contents($this->workingDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}');
|
||||
|
||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_1');
|
||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
|
||||
|
||||
// Assert that autoload_namespaces.php was correctly generated.
|
||||
$this->assertAutoloadFiles('main', $this->vendorDir.'/composer');
|
||||
|
|
|
@ -6,5 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Acme\\Cake\\ClassMapBar' => $baseDir . '/src-cake/ClassMapBar.php',
|
||||
'ClassMapFoo' => $baseDir . '/composersrc/foo.php',
|
||||
'Lala\\ClassMapMain' => $baseDir . '/src/Lala/ClassMapMain.php',
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue