MediaWiki REL1_33
AutoLoaderTest.php
Go to the documentation of this file.
1<?php
2
7
8 private $oldPsr4;
9
10 protected function setUp() {
11 parent::setUp();
12
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',
21 ] );
23
24 $this->mergeMwGlobalArrayValue( 'wgAutoloadClasses', [
25 'TestAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedClass.php',
26 ] );
27
28 $this->oldPsr4 = AutoLoader::$psr4Namespaces;
29 AutoLoader::$psr4Namespaces['Test\\MediaWiki\\AutoLoader\\'] =
30 __DIR__ . '/../data/autoloader/psr4';
31 }
32
33 protected function tearDown() {
35 parent::tearDown();
36 }
37
38 public function testCoreClass() {
39 $this->assertTrue( class_exists( 'TestAutoloadedLocalClass' ) );
40 }
41
42 public function testExtensionClass() {
43 $this->assertTrue( class_exists( 'TestAutoloadedClass' ) );
44 }
45
46 public function testWrongCaseClass() {
47 $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true );
48
49 $this->assertTrue( class_exists( 'testautoLoadedcamlCLASS' ) );
50 }
51
52 public function testWrongCaseSerializedClass() {
53 $this->setMwGlobals( 'wgAutoloadAttemptLowercase', true );
54
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." );
59 }
60
61 public function testPsr4() {
62 $this->assertTrue( class_exists( 'Test\\MediaWiki\\AutoLoader\\TestFooBar' ) );
63 }
64}
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
static string[] $psr4Namespaces
static resetAutoloadLocalClassesLower()
Method to clear the protected class property $autoloadLocalClassesLower.
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.