summaryrefslogtreecommitdiff
path: root/tests/phpunit/MediaWikiLangTestCase.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-04-01 06:11:44 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-04-01 06:11:44 +0200
commit14f74d141ab5580688bfd46d2f74c026e43ed967 (patch)
tree081b7cbfc4d246ecc42831978d080331267cf57c /tests/phpunit/MediaWikiLangTestCase.php
parent4a953b6bfda28604979feb9cfbb58974d13b84bb (diff)
Update to MediaWiki 1.24.2
Diffstat (limited to 'tests/phpunit/MediaWikiLangTestCase.php')
-rw-r--r--tests/phpunit/MediaWikiLangTestCase.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/phpunit/MediaWikiLangTestCase.php b/tests/phpunit/MediaWikiLangTestCase.php
new file mode 100644
index 00000000..53e67224
--- /dev/null
+++ b/tests/phpunit/MediaWikiLangTestCase.php
@@ -0,0 +1,32 @@
+<?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( array(
+ 'wgLanguageCode' => $langCode,
+ 'wgLang' => $langObj,
+ 'wgContLang' => $langObj,
+ ) );
+
+ MessageCache::singleton()->disable();
+ }
+}