Remove hard deprecation of PasswordPolicyChecks::checkPopularPasswordBlacklist
[lhc/web/wiklou.git] / tests / phpunit / includes / AutoLoaderTest.php
1 <?php
2
3 /**
4 * @covers AutoLoader
5 */
6 class AutoLoaderTest extends MediaWikiTestCase {
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 ] );
22 AutoLoader::resetAutoloadLocalClassesLower();
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() {
34 AutoLoader::$psr4Namespaces = $this->oldPsr4;
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 }