From f15eaf643a8163b9464a15415d4ba75cdba56ebb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 21 Aug 2021 15:26:11 +0200 Subject: [PATCH] ClassMapGeneratorTest: merge two tests As hitting the backtrace limit is now no longer an issue, the tests with the long heredoc/nowdocs can be merged into the `testCreateMap()` test method. I've verified that the long heredoc from the original issue 10037 with the updated fix no longer throws the PHP 8.1 deprecation notice and still gets indexed correctly. --- .../Test/Autoload/ClassMapGeneratorTest.php | 25 ++---- .../VeryLongHeredoc.php | 0 .../VeryLongNowdoc.php | 0 .../VeryLongPHP73Heredoc.php | 0 .../VeryLongPHP73Nowdoc.php | 0 .../pcrebacktracelimit/StripNoise.php | 87 ------------------- 6 files changed, 6 insertions(+), 106 deletions(-) rename tests/Composer/Test/Autoload/Fixtures/{pcrebacktracelimit => classmap}/VeryLongHeredoc.php (100%) rename tests/Composer/Test/Autoload/Fixtures/{pcrebacktracelimit => classmap}/VeryLongNowdoc.php (100%) rename tests/Composer/Test/Autoload/Fixtures/{pcrebacktracelimit => classmap}/VeryLongPHP73Heredoc.php (100%) rename tests/Composer/Test/Autoload/Fixtures/{pcrebacktracelimit => classmap}/VeryLongPHP73Nowdoc.php (100%) delete mode 100644 tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index d367d72e0f3f..1109e64d2b72 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -60,6 +60,12 @@ public function getTestCreateMapTests() 'Foo\\Third' => realpath(__DIR__) . '/Fixtures/classmap/StripNoise.php', 'Foo\\SlashedA' => realpath(__DIR__) . '/Fixtures/classmap/BackslashLineEndingString.php', 'Foo\\SlashedB' => realpath(__DIR__) . '/Fixtures/classmap/BackslashLineEndingString.php', + 'Foo\\VeryLongHeredoc' => realpath(__DIR__) . '/Fixtures/classmap/VeryLongHeredoc.php', + 'Foo\\ClassAfterLongHereDoc' => realpath(__DIR__) . '/Fixtures/classmap/VeryLongHeredoc.php', + 'Foo\\VeryLongPHP73Heredoc' => realpath(__DIR__) . '/Fixtures/classmap/VeryLongPHP73Heredoc.php', + 'Foo\\VeryLongPHP73Nowdoc' => realpath(__DIR__) . '/Fixtures/classmap/VeryLongPHP73Nowdoc.php', + 'Foo\\ClassAfterLongNowDoc' => realpath(__DIR__) . '/Fixtures/classmap/VeryLongPHP73Nowdoc.php', + 'Foo\\VeryLongNowdoc' => realpath(__DIR__) . '/Fixtures/classmap/VeryLongNowdoc.php', 'Unicode\\↑\\↑' => realpath(__DIR__) . '/Fixtures/classmap/Unicode.php', 'ShortOpenTag' => realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTag.php', 'ShortOpenTagDocblock' => realpath(__DIR__) . '/Fixtures/classmap/ShortOpenTagDocblock.php', @@ -247,25 +253,6 @@ public function testDump() $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/VeryLongHeredoc.php b/tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongHeredoc.php similarity index 100% rename from tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php rename to tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongHeredoc.php diff --git a/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php b/tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongNowdoc.php similarity index 100% rename from tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php rename to tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongNowdoc.php diff --git a/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php b/tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongPHP73Heredoc.php similarity index 100% rename from tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php rename to tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongPHP73Heredoc.php diff --git a/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php b/tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongPHP73Nowdoc.php similarity index 100% rename from tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php rename to tests/Composer/Test/Autoload/Fixtures/classmap/VeryLongPHP73Nowdoc.php diff --git a/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php b/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php deleted file mode 100644 index 8f93e842751c..000000000000 --- a/tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php +++ /dev/null @@ -1,87 +0,0 @@ -'; - } - - public function test_simple_string() - { - return 'class FailSimpleString {}'; - } -}