6 class AutoLoaderTest
extends MediaWikiTestCase
{
7 protected function setUp() {
10 // Fancy dance to trigger a rebuild of AutoLoader::$autoloadLocalClassesLower
11 $this->mergeMwGlobalArrayValue( 'wgAutoloadLocalClasses', [
12 'TestAutoloadedLocalClass' =>
13 __DIR__
. '/../data/autoloader/TestAutoloadedLocalClass.php',
14 'TestAutoloadedCamlClass' =>
15 __DIR__
. '/../data/autoloader/TestAutoloadedCamlClass.php',
16 'TestAutoloadedSerializedClass' =>
17 __DIR__
. '/../data/autoloader/TestAutoloadedSerializedClass.php',
19 AutoLoader
::resetAutoloadLocalClassesLower();
21 $this->mergeMwGlobalArrayValue( 'wgAutoloadClasses', [
22 'TestAutoloadedClass' => __DIR__
. '/../data/autoloader/TestAutoloadedClass.php',
26 public function testCoreClass() {
27 $this->assertTrue( class_exists( 'TestAutoloadedLocalClass' ) );
30 public function testExtensionClass() {
31 $this->assertTrue( class_exists( 'TestAutoloadedClass' ) );
34 public function testWrongCaseClass() {
35 $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true );
37 $this->assertTrue( class_exists( 'testautoLoadedcamlCLASS' ) );
40 public function testWrongCaseSerializedClass() {
41 $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true );
43 $dummyCereal = 'O:29:"testautoloadedserializedclass":0:{}';
44 $uncerealized = unserialize( $dummyCereal );
45 $this->assertFalse( $uncerealized instanceof __PHP_Incomplete_Class
,
46 "unserialize() can load classes case-insensitively." );