X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fstructure%2FAutoLoaderTest.php;h=d45a58c5d38c7c78db1a362053c4303b792cdbad;hp=f36b51a7e9d14581a7aec5c43b04f2b274e82069;hb=1a40e0cc86b6ee0706606ded3ea243dfde4a414c;hpb=adae996840b9e782f6e14b21c433a83e37c3a74e diff --git a/tests/phpunit/structure/AutoLoaderTest.php b/tests/phpunit/structure/AutoLoaderTest.php index f36b51a7e9..d45a58c5d3 100644 --- a/tests/phpunit/structure/AutoLoaderTest.php +++ b/tests/phpunit/structure/AutoLoaderTest.php @@ -68,6 +68,7 @@ class AutoLoaderTest extends MediaWikiTestCase { } // We could use token_get_all() here, but this is faster + // Note: Keep in sync with ClassCollector $matches = []; preg_match_all( '/ ^ [\t ]* (?: @@ -78,6 +79,11 @@ class AutoLoaderTest extends MediaWikiTestCase { ([\'"]) (?P [^\'"]+) \g{-2} \s* , \s* ([\'"]) (?P [^\'"]+ ) \g{-2} \s* \) \s* ; + | + class_alias \s* \( \s* + (?P [a-zA-Z0-9_]+)::class \s* , \s* + ([\'"]) (?P [^\'"]+ ) \g{-2} \s* + \) \s* ; ) /imx', $contents, $matches, PREG_SET_ORDER ); @@ -95,11 +101,18 @@ class AutoLoaderTest extends MediaWikiTestCase { foreach ( $matches as $match ) { if ( !empty( $match['class'] ) ) { + // 'class Foo {}' $class = $fileNamespace . $match['class']; $actual[$class] = $file; $classesInFile[$class] = true; } else { - $aliasesInFile[$match['alias']] = $match['original']; + if ( !empty( $match['original'] ) ) { + // 'class_alias( "Foo", "Bar" );' + $aliasesInFile[$match['alias']] = $match['original']; + } else { + // 'class_alias( Foo::class, "Bar" );' + $aliasesInFile[$match['aliasString']] = $fileNamespace . $match['originalStatic']; + } } } @@ -148,6 +161,7 @@ class AutoLoaderTest extends MediaWikiTestCase { $path = realpath( __DIR__ . '/../../..' ); $oldAutoload = file_get_contents( $path . '/autoload.php' ); $generator = new AutoloadGenerator( $path, 'local' ); + $generator->setExcludePaths( array_values( AutoLoader::getAutoloadNamespaces() ) ); $generator->initMediaWikiDefault(); $newAutoload = $generator->getAutoload( 'maintenance/generateLocalAutoload.php' );