Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
32 lines
963 B
PHP
32 lines
963 B
PHP
<?php
|
|
|
|
/**
|
|
* Base class that store and restore the Language objects
|
|
*/
|
|
abstract class MediaWikiLangTestCase extends MediaWikiTestCase {
|
|
protected function setUp() {
|
|
global $wgLanguageCode, $wgContLang;
|
|
parent::setUp();
|
|
|
|
if ( $wgLanguageCode != $wgContLang->getCode() ) {
|
|
throw new MWException( "Error in MediaWikiLangTestCase::setUp(): " .
|
|
"\$wgLanguageCode ('$wgLanguageCode') is different from " .
|
|
"\$wgContLang->getCode() (" . $wgContLang->getCode() . ")" );
|
|
}
|
|
|
|
// HACK: Call getLanguage() so the real $wgContLang is cached as the user language
|
|
// rather than our fake one. This is to avoid breaking other, unrelated tests.
|
|
RequestContext::getMain()->getLanguage();
|
|
|
|
$langCode = 'en'; # For mainpage to be 'Main Page'
|
|
$langObj = Language::factory( $langCode );
|
|
|
|
$this->setMwGlobals( [
|
|
'wgLanguageCode' => $langCode,
|
|
'wgLang' => $langObj,
|
|
'wgContLang' => $langObj,
|
|
] );
|
|
|
|
MessageCache::singleton()->disable();
|
|
}
|
|
}
|