Skip to content

Commit

Permalink
ClassMapGeneratorTest: merge two tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl authored and Seldaek committed Aug 21, 2021
1 parent 40bd4b0 commit 3344844
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 106 deletions.
25 changes: 6 additions & 19 deletions tests/Composer/Test/Autoload/ClassMapGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down

This file was deleted.

0 comments on commit 3344844

Please sign in to comment.