summaryrefslogtreecommitdiff
path: root/tests/phpunit/MediaWikiLangTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/MediaWikiLangTestCase.php')
-rw-r--r--tests/phpunit/MediaWikiLangTestCase.php39
1 files changed, 15 insertions, 24 deletions
diff --git a/tests/phpunit/MediaWikiLangTestCase.php b/tests/phpunit/MediaWikiLangTestCase.php
index 6dd8ea35..1131385f 100644
--- a/tests/phpunit/MediaWikiLangTestCase.php
+++ b/tests/phpunit/MediaWikiLangTestCase.php
@@ -4,39 +4,30 @@
* Base class that store and restore the Language objects
*/
abstract class MediaWikiLangTestCase extends MediaWikiTestCase {
- private static $oldLang;
- private static $oldContLang;
-
- public function setUp() {
- global $wgLanguageCode, $wgLang, $wgContLang;
+ protected function setUp() {
+ global $wgLanguageCode, $wgContLang;
parent::setUp();
- self::$oldLang = $wgLang;
- self::$oldContLang = $wgContLang;
-
- if( $wgLanguageCode != $wgContLang->getCode() ) {
- throw new MWException("Error in MediaWikiLangTestCase::setUp(): " .
+ if ( $wgLanguageCode != $wgContLang->getCode() ) {
+ throw new MWException( "Error in MediaWikiLangTestCase::setUp(): " .
"\$wgLanguageCode ('$wgLanguageCode') is different from " .
"\$wgContLang->getCode() (" . $wgContLang->getCode() . ")" );
}
- $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
-
- $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
- MessageCache::singleton()->disable();
-
- }
+ // 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();
- public function tearDown() {
- global $wgContLang, $wgLang, $wgLanguageCode;
- $wgLang = self::$oldLang;
+ $langCode = 'en'; # For mainpage to be 'Main Page'
+ $langObj = Language::factory( $langCode );
- $wgContLang = self::$oldContLang;
- $wgLanguageCode = $wgContLang->getCode();
- self::$oldContLang = self::$oldLang = null;
+ $this->setMwGlobals( array(
+ 'wgLanguageCode' => $langCode,
+ 'wgLang' => $langObj,
+ 'wgContLang' => $langObj,
+ ) );
- parent::tearDown();
+ MessageCache::singleton()->disable();
}
-
}