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
This commit is contained in:
parent
7e6a9ce4ad
commit
60e4f3fd90
2 changed files with 8 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 ] );
|
||||
|
|
|
|||
Loading…
Reference in a new issue