mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
ClassMapGenerator: add tests for "long heredoc" bug
... to proof the existence of the bug and demonstrate the effect. Note: in the test the backtrack limit is being lowered (and restored back to the default afterwards) to prevent the tests needing ridiculously huge test fixture files.
This commit is contained in:
parent
c65bd832d6
commit
9588654ae3
6 changed files with 2222 additions and 0 deletions
|
@ -244,6 +244,25 @@ class ClassMapGeneratorTest extends TestCase
|
|||
$fs->removeDirectory($tempDir);
|
||||
}
|
||||
|
||||
public function testCreateMapDoesNotHitRegexBacktraceLimit()
|
||||
{
|
||||
$expected = array(
|
||||
'Foo\\StripNoise' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/StripNoise.php',
|
||||
'Foo\\VeryLongHeredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php',
|
||||
'Foo\\ClassAfterLongHereDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php',
|
||||
'Foo\\VeryLongPHP73Heredoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php',
|
||||
'Foo\\VeryLongPHP73Nowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php',
|
||||
'Foo\\ClassAfterLongNowDoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php',
|
||||
'Foo\\VeryLongNowdoc' => realpath(__DIR__) . '/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php',
|
||||
);
|
||||
|
||||
ini_set('pcre.backtrack_limit', '30000');
|
||||
$result = ClassMapGenerator::createMap(__DIR__ . '/Fixtures/pcrebacktracelimit');
|
||||
ini_restore('pcre.backtrack_limit');
|
||||
|
||||
$this->assertEqualsNormalized($expected, $result);
|
||||
}
|
||||
|
||||
protected function assertEqualsNormalized($expected, $actual, $message = '')
|
||||
{
|
||||
foreach ($expected as $ns => $path) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue