Merge "rdbms: avoid LoadBalancer::getConnection waste when using $groups"
[lhc/web/wiklou.git] / tests / phpunit / structure / AutoLoaderStructureTest.php
index 75e21ae..37babce 100644 (file)
@@ -1,8 +1,5 @@
 <?php
 
-/**
- * @coversNothing
- */
 class AutoLoaderStructureTest extends MediaWikiTestCase {
        /**
         * Assert that there were no classes loaded that are not registered with the AutoLoader.
@@ -49,7 +46,9 @@ class AutoLoaderStructureTest extends MediaWikiTestCase {
                        // Check that the expected class name (based on the filename) is the
                        // same as the one we found.
                        // Strip directory prefix from front of filename, and .php extension
-                       $abbrFileName = substr( substr( $file, strlen( $dir ) ), 0, -4 );
+                       $dirNameLength = strlen( realpath( $dir ) ) + 1; // +1 for the trailing slash
+                       $fileBaseName = substr( $file, $dirNameLength );
+                       $abbrFileName = substr( $fileBaseName, 0, -4 );
                        $expectedClassName = $prefix . str_replace( '/', '\\', $abbrFileName );
 
                        $this->assertSame(
@@ -112,14 +111,12 @@ class AutoLoaderStructureTest extends MediaWikiTestCase {
                                // 'class Foo {}'
                                $class = $fileNamespace . $match['class'];
                                $classesInFile[$class] = true;
+                       } elseif ( !empty( $match['original'] ) ) {
+                               // 'class_alias( "Foo", "Bar" );'
+                               $aliasesInFile[$match['alias']] = $match['original'];
                        } else {
-                               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'];
-                               }
+                               // 'class_alias( Foo::class, "Bar" );'
+                               $aliasesInFile[$match['aliasString']] = $fileNamespace . $match['originalStatic'];
                        }
                }