Merge "SpecialNewpages: add $attribs['class'] immediately before creating <li>"
[lhc/web/wiklou.git] / tests / parser / ParserTestRunner.php
index 8615edc..97c3c05 100644 (file)
@@ -341,8 +341,9 @@ class ParserTestRunner {
                MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
                MediaWikiServices::getInstance()->redefineService(
                        'MediaHandlerFactory',
-                       function () {
-                               return new MockMediaHandlerFactory();
+                       function ( MediaWikiServices $services ) {
+                               $handlers = $services->getMainConfig()->get( 'ParserTestMediaHandlers' );
+                               return new MediaHandlerFactory( $handlers );
                        }
                );
                $teardown[] = function () {
@@ -477,7 +478,7 @@ class ParserTestRunner {
         * @see staticSetup
         *
         * @param array $teardown The snippet array
-        * @param ScopedCallback|null A ScopedCallback to consume
+        * @param ScopedCallback|null $nextTeardown A ScopedCallback to consume
         * @return ScopedCallback
         */
        protected function createTeardownObject( $teardown, $nextTeardown = null ) {
@@ -526,7 +527,7 @@ class ParserTestRunner {
         * Determine whether a particular setup function has been run
         *
         * @param string $funcName
-        * @return boolean
+        * @return bool
         */
        public function isSetupDone( $funcName ) {
                return isset( $this->setupDone[$funcName] ) ? $this->setupDone[$funcName] : false;
@@ -1036,6 +1037,9 @@ class ParserTestRunner {
                $linkHolderBatchSize =
                        self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
 
+               // Default to fallback skin, but allow it to be overridden
+               $skin = self::getOptionValue( 'skin', $opts, 'fallback' );
+
                $setup = [
                        'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
                        'wgLanguageCode' => $langCode,
@@ -1052,6 +1056,8 @@ class ParserTestRunner {
                        // wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
                        'wgEnableMagicLinks' => self::getOptionValue( 'wgEnableMagicLinks', $opts, [] )
                                + [ 'ISBN' => true, 'PMID' => true, 'RFC' => true ],
+                       // Test with legacy encoding by default until HTML5 is very stable and default
+                       'wgFragmentMode' => [ 'legacy' ],
                ];
 
                if ( $config ) {
@@ -1105,7 +1111,13 @@ class ParserTestRunner {
                $context = RequestContext::getMain();
                $context->setUser( $user );
                $context->setLanguage( $lang );
-               $teardown[] = function () use ( $context ) {
+               // And the skin!
+               $oldSkin = $context->getSkin();
+               $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
+               $context->setSkin( $skinFactory->makeSkin( $skin ) );
+               $context->setOutput( new OutputPage( $context ) );
+               $setup['wgOut'] = $context->getOutput();
+               $teardown[] = function () use ( $context, $oldSkin ) {
                        // Clear language conversion tables
                        $wrapper = TestingAccessWrapper::newFromObject(
                                $context->getLanguage()->getConverter()
@@ -1114,6 +1126,8 @@ class ParserTestRunner {
                        // Reset context to the restored globals
                        $context->setUser( $GLOBALS['wgUser'] );
                        $context->setLanguage( $GLOBALS['wgContLang'] );
+                       $context->setSkin( $oldSkin );
+                       $context->setOutput( $GLOBALS['wgOut'] );
                };
 
                $teardown[] = $this->executeSetupSnippets( $setup );
@@ -1516,7 +1530,7 @@ class ParserTestRunner {
        /**
         * Add articles to the test DB.
         *
-        * @param $articles Article info array from TestFileReader
+        * @param array $articles Article info array from TestFileReader
         */
        public function addArticles( $articles ) {
                global $wgContLang;