diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index 1fb73c253..261fb7ced 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -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) { diff --git a/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php b/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php new file mode 100644 index 000000000..8f93e8427 --- /dev/null +++ b/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php @@ -0,0 +1,87 @@ +'; + } + + public function test_simple_string() + { + return 'class FailSimpleString {}'; + } +} diff --git a/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php b/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php new file mode 100644 index 000000000..11f87546d --- /dev/null +++ b/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php @@ -0,0 +1,464 @@ +