From dc4fb23cfa08dd9f36c626a230aae1fdcd1a3639 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 26 May 2018 21:29:36 -0700 Subject: [PATCH] Improve AutoLoader test coverage Change-Id: Iddb24cad41979a4798392ab08d104dac41ed736d --- includes/AutoLoader.php | 1 + .../phpunit/data/autoloader/psr4/TestFooBar.php | 6 ++++++ tests/phpunit/includes/AutoLoaderTest.php | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 tests/phpunit/data/autoloader/psr4/TestFooBar.php diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 62b1d39f3c..9fc063a285 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -123,6 +123,7 @@ class AutoLoader { * * @see * @private Only public for usage in AutoloadGenerator + * @codeCoverageIgnore * @since 1.31 * @return string[] */ diff --git a/tests/phpunit/data/autoloader/psr4/TestFooBar.php b/tests/phpunit/data/autoloader/psr4/TestFooBar.php new file mode 100644 index 0000000000..4a2e11f157 --- /dev/null +++ b/tests/phpunit/data/autoloader/psr4/TestFooBar.php @@ -0,0 +1,6 @@ +mergeMwGlobalArrayValue( 'wgAutoloadClasses', [ 'TestAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedClass.php', ] ); + + $this->oldPsr4 = AutoLoader::$psr4Namespaces; + AutoLoader::$psr4Namespaces['Test\\MediaWiki\\AutoLoader\\'] = + __DIR__ . '/../data/autoloader/psr4'; + } + + protected function tearDown() { + AutoLoader::$psr4Namespaces = $this->oldPsr4; + parent::tearDown(); } public function testCoreClass() { @@ -45,4 +57,8 @@ class AutoLoaderTest extends MediaWikiTestCase { $this->assertFalse( $uncerealized instanceof __PHP_Incomplete_Class, "unserialize() can load classes case-insensitively." ); } + + public function testPsr4() { + $this->assertTrue( class_exists( 'Test\\MediaWiki\\AutoLoader\\TestFooBar' ) ); + } } -- 2.20.1