6 class AutoLoaderTest
extends MediaWikiTestCase
{
10 protected function setUp() {
13 // Fancy dance to trigger a rebuild of AutoLoader::$autoloadLocalClassesLower
14 $this->mergeMwGlobalArrayValue( 'wgAutoloadLocalClasses', [
15 'TestAutoloadedLocalClass' =>
16 __DIR__
. '/../data/autoloader/TestAutoloadedLocalClass.php',
17 'TestAutoloadedCamlClass' =>
18 __DIR__
. '/../data/autoloader/TestAutoloadedCamlClass.php',
19 'TestAutoloadedSerializedClass' =>
20 __DIR__
. '/../data/autoloader/TestAutoloadedSerializedClass.php',
22 AutoLoader
::resetAutoloadLocalClassesLower();
24 $this->mergeMwGlobalArrayValue( 'wgAutoloadClasses', [
25 'TestAutoloadedClass' => __DIR__
. '/../data/autoloader/TestAutoloadedClass.php',
28 $this->oldPsr4
= AutoLoader
::$psr4Namespaces;
29 AutoLoader
::$psr4Namespaces['Test\\MediaWiki\\AutoLoader\\'] =
30 __DIR__
. '/../data/autoloader/psr4';
33 protected function tearDown() {
34 AutoLoader
::$psr4Namespaces = $this->oldPsr4
;
38 public function testCoreClass() {
39 $this->assertTrue( class_exists( 'TestAutoloadedLocalClass' ) );
42 public function testExtensionClass() {
43 $this->assertTrue( class_exists( 'TestAutoloadedClass' ) );
46 public function testWrongCaseClass() {
47 $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true );
49 $this->assertTrue( class_exists( 'testautoLoadedcamlCLASS' ) );
52 public function testWrongCaseSerializedClass() {
53 $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true );
55 $dummyCereal = 'O:29:"testautoloadedserializedclass":0:{}';
56 $uncerealized = unserialize( $dummyCereal );
57 $this->assertFalse( $uncerealized instanceof __PHP_Incomplete_Class
,
58 "unserialize() can load classes case-insensitively." );
61 public function testPsr4() {
62 $this->assertTrue( class_exists( 'Test\\MediaWiki\\AutoLoader\\TestFooBar' ) );