diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /tests/phpunit/structure/AutoLoaderTest.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'tests/phpunit/structure/AutoLoaderTest.php')
-rw-r--r-- | tests/phpunit/structure/AutoLoaderTest.php | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/tests/phpunit/structure/AutoLoaderTest.php b/tests/phpunit/structure/AutoLoaderTest.php index 2bdc9c9a..cde6547a 100644 --- a/tests/phpunit/structure/AutoLoaderTest.php +++ b/tests/phpunit/structure/AutoLoaderTest.php @@ -2,27 +2,22 @@ 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 ); + ) ); } /** @@ -49,7 +44,7 @@ class AutoLoaderTest extends MediaWikiTestCase { $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 ) != ':' ) { @@ -58,7 +53,19 @@ class AutoLoaderTest extends MediaWikiTestCase { $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(); @@ -123,10 +130,14 @@ class AutoLoaderTest extends MediaWikiTestCase { } function testWrongCaseClass() { + $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true ); + $this->assertTrue( class_exists( 'testautoLoadedcamlCLASS' ) ); } function testWrongCaseSerializedClass() { + $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true ); + $dummyCereal = 'O:29:"testautoloadedserializedclass":0:{}'; $uncerealized = unserialize( $dummyCereal ); $this->assertFalse( $uncerealized instanceof __PHP_Incomplete_Class, |