From f45e4de3b748963a70512ad0684aaba409461780 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 15 Jul 2014 17:49:18 -0700 Subject: [PATCH] Make AutoLoaderTest handle namespaces Bug: 67644 Change-Id: Ibeb0833742c574afac13bfebd278f9d2b8410de6 --- tests/phpunit/structure/AutoLoaderTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/structure/AutoLoaderTest.php b/tests/phpunit/structure/AutoLoaderTest.php index 12f147e9bd..2bdc9c9a22 100644 --- a/tests/phpunit/structure/AutoLoaderTest.php +++ b/tests/phpunit/structure/AutoLoaderTest.php @@ -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']; } -- 2.20.1