Merge "Makes WebRequest::detectProtocolAndStdPort() take HTTP_X_FORWARDED_PROTO heade...
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiLangTestCase.php
index 5ab4344..3034601 100644 (file)
@@ -4,29 +4,26 @@
  * 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;
-               
-               self::$oldLang = $wgLang;
-               self::$oldContLang = $wgContLang;
-               
-               if( $wgLanguageCode != $wgContLang->getCode() ) die("nooo!");
-                               
-               $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
+       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() . ")" );
+               }
+
+               $langCode = 'en'; # For mainpage to be 'Main Page'
+               $langObj = Language::factory( $langCode );
+
+               $this->setMwGlobals( array(
+                       'wgLanguageCode' => $langCode,
+                       'wgLang' => $langObj,
+                       'wgContLang' => $langObj,
+               ) );
 
-               $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
                MessageCache::singleton()->disable();
        }
-       
-       public function tearDown() {
-               global $wgContLang, $wgLang, $wgLanguageCode;
-               $wgLang = self::$oldLang;
-               
-               $wgContLang = self::$oldContLang;
-               $wgLanguageCode = $wgContLang->getCode();
-       }
-       
 }