Fix the old XmlTest.php test bug in the dateMenu() when the wiki is configured for...
authorPlatonides <platonides@users.mediawiki.org>
Sun, 1 May 2011 19:32:49 +0000 (19:32 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Sun, 1 May 2011 19:32:49 +0000 (19:32 +0000)
Other tests were running before and messing with the Language objects.

tests/phpunit/MediaWikiLangTestCase.php [new file with mode: 0644]
tests/phpunit/includes/LanguageConverterTest.php
tests/phpunit/includes/MessageTest.php
tests/phpunit/includes/SampleTest.php
tests/phpunit/includes/XmlTest.php

diff --git a/tests/phpunit/MediaWikiLangTestCase.php b/tests/phpunit/MediaWikiLangTestCase.php
new file mode 100644 (file)
index 0000000..9c514bb
--- /dev/null
@@ -0,0 +1,32 @@
+<?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();
+       }
+       
+}
index d26db94..d084540 100644 (file)
@@ -1,10 +1,12 @@
 <?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;
index c562611..02e03ed 100644 (file)
@@ -1,15 +1,6 @@
 <?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() );
index fa7c4d5..fc7881a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-class TestSample extends MediaWikiTestCase {
+class TestSample extends MediaWikiLangTestCase {
 
        /**
         * Anything that needs to happen before your tests should go here.
index d9647e5..d0c364e 100644 (file)
@@ -1,6 +1,21 @@
 <?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),