X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fcommon%2FTestsAutoLoader.php;h=10e853b4fa023968545579242dee2392e8e785f7;hb=6a2cd1c5c22b6dd79fbc1ef65bf3b6e1d92b8fb7;hp=82149b3737761f2943b1985c193c92306dd6d81d;hpb=64f08b23ee6f29cd38289f8d48bad7469d248107;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/common/TestsAutoLoader.php b/tests/common/TestsAutoLoader.php index 82149b3737..10e853b4fa 100644 --- a/tests/common/TestsAutoLoader.php +++ b/tests/common/TestsAutoLoader.php @@ -63,6 +63,8 @@ $wgAutoloadClasses += [ 'TestUserRegistry' => "$testDir/phpunit/includes/TestUserRegistry.php", 'LessFileCompilationTest' => "$testDir/phpunit/LessFileCompilationTest.php", 'MediaWikiCoversValidator' => "$testDir/phpunit/MediaWikiCoversValidator.php", + 'PHPUnit4And6Compat' => "$testDir/phpunit/PHPUnit4And6Compat.php", + 'HamcrestPHPUnitIntegration' => "$testDir/phpunit/HamcrestPHPUnitIntegration.php", # tests/phpunit/includes 'RevisionDbTestBase' => "$testDir/phpunit/includes/RevisionDbTestBase.php", @@ -77,6 +79,7 @@ $wgAutoloadClasses += [ 'ApiTestCase' => "$testDir/phpunit/includes/api/ApiTestCase.php", 'ApiTestCaseUpload' => "$testDir/phpunit/includes/api/ApiTestCaseUpload.php", 'ApiTestContext' => "$testDir/phpunit/includes/api/ApiTestContext.php", + 'ApiUploadTestCase' => "$testDir/phpunit/includes/api/ApiUploadTestCase.php", 'MockApi' => "$testDir/phpunit/includes/api/MockApi.php", 'MockApiQueryBase' => "$testDir/phpunit/includes/api/MockApiQueryBase.php", 'UserWrapper' => "$testDir/phpunit/includes/api/UserWrapper.php", @@ -95,6 +98,8 @@ $wgAutoloadClasses += [ 'DummyContentForTesting' => "$testDir/phpunit/mocks/content/DummyContentForTesting.php", 'DummyNonTextContentHandler' => "$testDir/phpunit/mocks/content/DummyNonTextContentHandler.php", 'DummyNonTextContent' => "$testDir/phpunit/mocks/content/DummyNonTextContent.php", + 'DummySerializeErrorContentHandler' => + "$testDir/phpunit/mocks/content/DummySerializeErrorContentHandler.php", 'ContentHandlerTest' => "$testDir/phpunit/includes/content/ContentHandlerTest.php", 'JavaScriptContentTest' => "$testDir/phpunit/includes/content/JavaScriptContentTest.php", 'TextContentTest' => "$testDir/phpunit/includes/content/TextContentTest.php", @@ -143,6 +148,9 @@ $wgAutoloadClasses += [ 'SpecialPageTestBase' => "$testDir/phpunit/includes/specials/SpecialPageTestBase.php", 'SpecialPageExecutor' => "$testDir/phpunit/includes/specials/SpecialPageExecutor.php", + # tests/phpunit/includes/Storage + 'MediaWiki\Tests\Storage\RevisionSlotsTest' => "$testDir/phpunit/includes/Storage/RevisionSlotsTest.php", + # tests/phpunit/languages 'LanguageClassesTestCase' => "$testDir/phpunit/languages/LanguageClassesTestCase.php", @@ -171,9 +179,43 @@ $wgAutoloadClasses += [ 'MediaWiki\\Session\\DummySessionBackend' => "$testDir/phpunit/mocks/session/DummySessionBackend.php", 'DummySessionProvider' => "$testDir/phpunit/mocks/session/DummySessionProvider.php", + 'MockMessageLocalizer' => "$testDir/phpunit/mocks/MockMessageLocalizer.php", # tests/suites 'ParserTestFileSuite' => "$testDir/phpunit/suites/ParserTestFileSuite.php", 'ParserTestTopLevelSuite' => "$testDir/phpunit/suites/ParserTestTopLevelSuite.php", ]; // phpcs:enable + +/** + * Alias any PHPUnit 4 era PHPUnit_... class + * to it's PHPUnit 6 replacement. For most classes + * this is a direct _ -> \ replacement, but for + * some others we might need to maintain a manual + * mapping. Once we drop support for PHPUnit 4 this + * should be considered deprecated and eventually removed. + */ +spl_autoload_register( function ( $class ) { + if ( strpos( $class, 'PHPUnit_' ) !== 0 ) { + // Skip if it doesn't start with the old prefix + return; + } + + // Classes that don't map 100% + $map = [ + 'PHPUnit_Framework_TestSuite_DataProvider' => 'PHPUnit\Framework\DataProviderTestSuite', + 'PHPUnit_Framework_Error' => 'PHPUnit\Framework\Error\Error', + ]; + + if ( isset( $map[$class] ) ) { + $newForm = $map[$class]; + } else { + $newForm = str_replace( '_', '\\', $class ); + } + + if ( class_exists( $newForm ) || interface_exists( $newForm ) ) { + // If the new class name exists, alias + // the old name to it. + class_alias( $newForm, $class ); + } +} );