Localisation updates from http://translatewiki.net.
[mediawiki.git] / tests / phpunit / structure / AutoLoaderTest.php
blobe49ea6d9783a22374c9d75b2513acfd0ec93a89c
1 <?php
2 class AutoLoaderTest extends MediaWikiTestCase {
4 public function testAutoLoadConfig() {
5 $results = self::checkAutoLoadConf();
7 $this->assertEquals(
8 $results['expected'],
9 $results['actual']
13 protected static function checkAutoLoadConf() {
14 global $wgAutoloadLocalClasses, $wgAutoloadClasses, $IP;
15 $supportsParsekit = function_exists( 'parsekit_compile_file' );
17 // wgAutoloadLocalClasses has precedence, just like in includes/AutoLoader.php
18 $expected = $wgAutoloadLocalClasses + $wgAutoloadClasses;
19 $actual = array();
21 $files = array_unique( $expected );
23 foreach ( $files as $file ) {
24 // Only prefix $IP if it doesn't have it already.
25 // Generally local classes don't have it, and those from extensions and test suites do.
26 if ( substr( $file, 0, 1 ) != '/' && substr( $file, 1, 1 ) != ':' ) {
27 $filePath = "$IP/$file";
28 } else {
29 $filePath = $file;
31 if ( $supportsParsekit ) {
32 $parseInfo = parsekit_compile_file( "$filePath" );
33 $classes = array_keys( $parseInfo['class_table'] );
34 } else {
35 $contents = file_get_contents( "$filePath" );
36 $m = array();
37 preg_match_all( '/\n\s*(?:final)?\s*(?:abstract)?\s*(?:class|interface)\s+([a-zA-Z0-9_]+)/', $contents, $m, PREG_PATTERN_ORDER );
38 $classes = $m[1];
40 foreach ( $classes as $class ) {
41 $actual[$class] = $file;
45 return array(
46 'expected' => $expected,
47 'actual' => $actual,