Merge "add htmlform-no and htmlform-yes messages for generic yes-no questions"
[lhc/web/wiklou.git] / tests / phpunit / AutoLoaderTest.php
1 <?php
2 class AutoLoaderTest extends MediaWikiTestCase {
3
4 public function testAutoLoadConfig() {
5 $results = self::checkAutoLoadConf();
6
7 $this->assertEquals(
8 $results['expected'],
9 $results['actual']
10 );
11 }
12
13 protected static function checkAutoLoadConf() {
14 global $wgAutoloadLocalClasses, $wgAutoloadClasses, $IP;
15 $supportsParsekit = function_exists( 'parsekit_compile_file' );
16
17 // wgAutoloadLocalClasses has precedence, just like in includes/AutoLoader.php
18 $expected = $wgAutoloadLocalClasses + $wgAutoloadClasses;
19 $actual = array();
20
21 $files = array_unique( $expected );
22
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;
30 }
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];
39 }
40 foreach ( $classes as $class ) {
41 $actual[$class] = $file;
42 }
43 }
44
45 return array(
46 'expected' => $expected,
47 'actual' => $actual,
48 );
49 }
50 }