From 7916919c810a2385c1481423a999b972c349e388 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 19 Jul 2017 18:42:56 -0700 Subject: [PATCH] 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 --- tests/parser/ParserTestRunner.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 ); -- 2.20.1