1
0
Fork 0

Fix tests for PSR-fix in optimized autoloader, refs #8397

pull/8406/head
Jordi Boggiano 2019-11-01 15:31:55 +01:00
parent c3f034e33b
commit 502b68967a
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 4 additions and 17 deletions

View File

@ -189,7 +189,7 @@ class ClassMapGenerator
//return array();
}
// TODO enable in Composer v1.11 or 2.0 whichever comes first
// TODO enable in Composer v1.11 or 2.0 whichever comes first & unskip test in AutoloadGeneratorTest::testPSRToClassMapIgnoresNonPSRClasses
//return $validClasses;
return $classes;
}

View File

@ -552,6 +552,8 @@ class AutoloadGeneratorTest extends TestCase
{
$package = new Package('a', '1.0', '1.0');
$this->markTestSkipped('Skipped until ClassMapGenerator ignoring of invalid PSR-x classes is enabled');
$package->setAutoload(array(
'psr-0' => array('psr0_' => 'psr0/'),
'psr-4' => array('psr4\\' => 'psr4/'),
@ -568,20 +570,7 @@ class AutoloadGeneratorTest extends TestCase
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 {}');
set_error_handler(function ($errno, $errstr) {
if ($errno !== E_USER_DEPRECATED || !preg_match('{^Class (psr4\\\\badclass|psr0_badclass) located in .+? does not comply with psr-[04] autoloading standard}', $errstr)) {
throw new \UnexpectedValueException('Unexpected error: '.$errstr);
}
});
try {
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
} catch (\Exception $e) {
restore_error_handler();
throw $e;
}
restore_error_handler();
$this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated.");
$expectedClassmap = <<<EOF
@ -593,9 +582,7 @@ class AutoloadGeneratorTest extends TestCase
\$baseDir = dirname(\$vendorDir);
return array(
'psr0_badclass' => \$baseDir . '/psr0/psr0/badfile.php',
'psr0_match' => \$baseDir . '/psr0/psr0/match.php',
'psr4\\\\badclass' => \$baseDir . '/psr4/badfile.php',
'psr4\\\\match' => \$baseDir . '/psr4/match.php',
);