mirror of
https://github.com/composer/composer
synced 2025-05-09 08:32:56 +00:00
make optimized autoloader respect PSR standards
This commit is contained in:
parent
eea4098f98
commit
ec293adabc
3 changed files with 118 additions and 14 deletions
|
@ -548,6 +548,45 @@ class AutoloadGeneratorTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testPSRToClassMapIgnoresNonPSRClasses()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('psr0_' => 'psr0/'),
|
||||
'psr-4' => array('psr4\\' => 'psr4/'),
|
||||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/psr0/psr0');
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/psr4');
|
||||
file_put_contents($this->workingDir.'/psr0/psr0/match.php', '<?php class psr0_match {}');
|
||||
file_put_contents($this->workingDir.'/psr0/psr0/badfile.php', '<?php class psr0_badclass {}');
|
||||
file_put_contents($this->workingDir.'/psr4/match.php', '<?php namespace psr4; class match {}');
|
||||
file_put_contents($this->workingDir.'/psr4/badfile.php', '<?php namespace psr4; class badclass {}');
|
||||
|
||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
|
||||
$this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
|
||||
$expectedClassmap = <<<EOF
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
\$vendorDir = dirname(dirname(__FILE__));
|
||||
\$baseDir = dirname(\$vendorDir);
|
||||
|
||||
return array(
|
||||
'psr0_match' => \$baseDir . '/psr0/psr0/match.php',
|
||||
'psr4\\\\match' => \$baseDir . '/psr4/match.php',
|
||||
);
|
||||
|
||||
EOF;
|
||||
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
|
||||
}
|
||||
|
||||
public function testVendorsClassMapAutoloading()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue