From: Kunal Mehta Date: Thu, 20 Jul 2017 01:42:56 +0000 (-0700) Subject: parserTests: Use "fallback" skin unless otherwise specified X-Git-Tag: 1.31.0-rc.0~2591^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=7916919c810a2385c1481423a999b972c349e388 parserTests: Use "fallback" skin unless otherwise specified ParserOutput::getText() depends on the current skin to format edit section links, which some (e.g. MinervaNeue) have customized. This causes parser tests to fail when they expect the default edit section link format. Default to always using the built-in fallback skin when parsing, but allow it to be overridden with a "skin=..." option. We also have to override $wgOut in addition to the main RequestContext since that's what ParserOutput uses. Bug: T170880 Change-Id: Ib7f0bd15dd0a9255e1e5140907e800478b658b92 --- diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 9255733e74..fff1eec78e 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -1036,6 +1036,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, @@ -1105,7 +1108,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 +1123,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 );