Other tests were running before and messing with the Language objects.
--- /dev/null
+<?php
+
+/**
+ * Base class that store and restore the Language objects
+ */
+class MediaWikiLangTestCase extends MediaWikiTestCase {
+ private static $oldLang;
+ private static $oldContLang;
+
+ public function setUp() {
+ global $wgLanguageCode, $wgLang, $wgContLang;
+
+ self::$oldLang = $wgLang;
+ self::$oldContLang = $wgContLang;
+
+ if( $wgLanguageCode != $wgContLang->getCode() ) die("nooo!");
+
+ $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
+
+ $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
+ MessageCache::singleton()->disable();
+ }
+
+ public function tearDown() {
+ global $wgContLang, $wgLang, $wgLanguageCode;
+ $wgLang = self::$oldLang;
+
+ $wgContLang = self::$oldContLang;
+ $wgLanguageCode = $wgContLang->getCode();
+ }
+
+}
<?php
-class LanguageConverterTest extends MediaWikiTestCase {
+
+class LanguageConverterTest extends MediaWikiLangTestCase {
protected $lang = null;
protected $lc = null;
function setUp() {
+ parent::setUp();
global $wgMemc, $wgRequest, $wgUser, $wgContLang;
$wgUser = new User;
<?php
-class MessageTest extends MediaWikiTestCase {
-
- function setUp() {
- global $wgLanguageCode, $wgLang, $wgContLang;
-
- $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
- //Note that a Stub Object is not enough for this test
- $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
- MessageCache::singleton()->disable();
- }
+class MessageTest extends MediaWikiLangTestCase {
function testExists() {
$this->assertTrue( wfMessage( 'mainpage' )->exists() );
<?php
-class TestSample extends MediaWikiTestCase {
+class TestSample extends MediaWikiLangTestCase {
/**
* Anything that needs to happen before your tests should go here.
<?php
class XmlTest extends MediaWikiTestCase {
+ private static $oldLang;
+
+ public function setUp() {
+ global $wgLang, $wgLanguageCode;
+
+ self::$oldLang = $wgLang;
+ $wgLanguageCode = 'en';
+ $wgLang = Language::factory( $wgLanguageCode );
+ }
+
+ public function tearDown() {
+ global $wgContLang, $wgLanguageCode;
+ $wgLang = self::$oldLang;
+ $wgLanguageCode = $wgLang->getCode();
+ }
public function testExpandAttributes() {
$this->assertNull( Xml::expandAttributes(null),