From: Timo Tijhof Date: Tue, 1 Mar 2016 21:46:35 +0000 (+0000) Subject: tests: Ensure main RequestContext reflects custom $wgLang X-Git-Tag: 1.31.0-rc.0~7749^2 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=60e4f3fd90abf1aced88846138ba9ede66571bda;p=lhc%2Fweb%2Fwiklou.git tests: Ensure main RequestContext reflects custom $wgLang Call RequestContext::resetMain() so that any subsequent call to getMain() and getLanguage() is aware of the latest state as set up by the setUp() and setupGlobals() methods. The MediaWikiTestCase class for PHPUnit did this already, but the parserTest suite and UploadFromUrlTestSuite didn't yet. Change-Id: I6481176228944004091078704d0346c8f3fc0cf1 --- diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index c42ff30634..9f453075cb 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -227,12 +227,13 @@ class ParserTest { $messageMemc = wfGetMessageCacheStorage(); $parserMemc = wfGetParserCacheStorage(); - $wgUser = new User; + RequestContext::resetMain(); $context = new RequestContext; + $wgUser = new User; $wgLang = $context->getLanguage(); $wgOut = $context->getOutput(); - $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], [ $wgParserConf ] ); $wgRequest = $context->getRequest(); + $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], [ $wgParserConf ] ); if ( $wgStyleDirectory === false ) { $wgStyleDirectory = "$IP/skins"; @@ -931,10 +932,12 @@ class ParserTest { $GLOBALS[$var] = $val; } + // Must be set before $context as user language defaults to $wgContLang $GLOBALS['wgContLang'] = Language::factory( $lang ); $GLOBALS['wgMemc'] = new EmptyBagOStuff; - $context = new RequestContext(); + RequestContext::resetMain(); + $context = RequestContext::getMain(); $GLOBALS['wgLang'] = $context->getLanguage(); $GLOBALS['wgOut'] = $context->getOutput(); $GLOBALS['wgUser'] = $context->getUser(); diff --git a/tests/phpunit/suites/UploadFromUrlTestSuite.php b/tests/phpunit/suites/UploadFromUrlTestSuite.php index 9ff79a5e58..e3c5118e7a 100644 --- a/tests/phpunit/suites/UploadFromUrlTestSuite.php +++ b/tests/phpunit/suites/UploadFromUrlTestSuite.php @@ -63,8 +63,9 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite { $messageMemc = wfGetMessageCacheStorage(); $parserMemc = wfGetParserCacheStorage(); + RequestContext::resetMain(); + $context = RequestContext::getMain(); $wgUser = new User; - $context = new RequestContext; $wgLang = $context->getLanguage(); $wgOut = $context->getOutput(); $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], [ $wgParserConf ] );