class AutoLoaderTest extends MediaWikiTestCase {
protected function setUp() {
- global $wgAutoloadLocalClasses, $wgAutoloadClasses;
-
parent::setUp();
// Fancy dance to trigger a rebuild of AutoLoader::$autoloadLocalClassesLower
- $this->testLocalClasses = array(
- 'TestAutoloadedLocalClass' => __DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php',
- 'TestAutoloadedCamlClass' => __DIR__ . '/../data/autoloader/TestAutoloadedCamlClass.php',
+ $this->mergeMwGlobalArrayValue( 'wgAutoloadLocalClasses', array(
+ 'TestAutoloadedLocalClass' =>
+ __DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php',
+ 'TestAutoloadedCamlClass' =>
+ __DIR__ . '/../data/autoloader/TestAutoloadedCamlClass.php',
'TestAutoloadedSerializedClass' =>
__DIR__ . '/../data/autoloader/TestAutoloadedSerializedClass.php',
- );
- $this->setMwGlobals(
- 'wgAutoloadLocalClasses',
- $this->testLocalClasses + $wgAutoloadLocalClasses
- );
+ ) );
AutoLoader::resetAutoloadLocalClassesLower();
- $this->testExtensionClasses = array(
+ $this->mergeMwGlobalArrayValue( 'wgAutoloadClasses', array(
'TestAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedClass.php',
- );
- $this->setMwGlobals( 'wgAutoloadClasses', $this->testExtensionClasses + $wgAutoloadClasses );
+ ) );
}
/**
$files = array_unique( $expected );
- foreach ( $files as $file ) {
+ foreach ( $files as $class => $file ) {
// Only prefix $IP if it doesn't have it already.
// Generally local classes don't have it, and those from extensions and test suites do.
if ( substr( $file, 0, 1 ) != '/' && substr( $file, 1, 1 ) != ':' ) {
$filePath = $file;
}
+ if ( !file_exists( $filePath ) ) {
+ $actual[$class] = "[file '$filePath' does not exist]";
+ continue;
+ }
+
+ wfSuppressWarnings();
$contents = file_get_contents( $filePath );
+ wfRestoreWarnings();
+
+ if ( $contents === false ) {
+ $actual[$class] = "[couldn't read file '$filePath']";
+ continue;
+ }
// We could use token_get_all() here, but this is faster
$matches = array();