Make AutoLoaderTest handle namespaces
authorChad Horohoe <chadh@wikimedia.org>
Wed, 16 Jul 2014 00:49:18 +0000 (17:49 -0700)
committerChad <chadh@wikimedia.org>
Wed, 16 Jul 2014 17:32:21 +0000 (17:32 +0000)
Bug: 67644
Change-Id: Ibeb0833742c574afac13bfebd278f9d2b8410de6

tests/phpunit/structure/AutoLoaderTest.php

index 12f147e..2bdc9c9 100644 (file)
@@ -74,13 +74,23 @@ class AutoLoaderTest extends MediaWikiTestCase {
                                )
                        /imx', $contents, $matches, PREG_SET_ORDER );
 
+                       $namespaceMatch = array();
+                       preg_match( '/
+                               ^ [\t ]*
+                                       namespace \s+
+                                               ([a-zA-Z0-9_]+(\\\\[a-zA-Z0-9_]+)*)
+                                       \s* ;
+                       /imx', $contents, $namespaceMatch );
+                       $fileNamespace = $namespaceMatch ? $namespaceMatch[1] . '\\' : '';
+
                        $classesInFile = array();
                        $aliasesInFile = array();
 
                        foreach ( $matches as $match ) {
                                if ( !empty( $match['class'] ) ) {
-                                       $actual[$match['class']] = $file;
-                                       $classesInFile[$match['class']] = true;
+                                       $class = $fileNamespace . $match['class'];
+                                       $actual[$class] = $file;
+                                       $classesInFile[$class] = true;
                                } else {
                                        $aliasesInFile[$match['alias']] = $match['original'];
                                }