Made tests more independent. Some items were only working before previous ones left...
authorPlatonides <platonides@users.mediawiki.org>
Wed, 11 Aug 2010 21:22:40 +0000 (21:22 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Wed, 11 Aug 2010 21:22:40 +0000 (21:22 +0000)
maintenance/tests/ApiWatchTest.php
maintenance/tests/ExtraParserTest.php
maintenance/tests/LanguageConverterTest.php
maintenance/tests/MessageTest.php
maintenance/tests/SearchDbTest.php
maintenance/tests/SearchUpdateTest.php
maintenance/tests/TitlePermissionTest.php
maintenance/tests/UploadTest.php

index 6153643..c673c70 100644 (file)
@@ -6,8 +6,18 @@ class ApiWatchTest extends ApiTestSetup {
                ini_set( 'log_errors', 1 );
                ini_set( 'error_reporting', 1 );
                ini_set( 'display_errors', 1 );
+
+               global $wgMemc;
+               $wgMemc = new FakeMemCachedClient;
        }
 
+       function tearDown() {
+               global $wgMemc;
+
+               $wgMemc = null;
+       }
+
+
        function doApiRequest( $params, $data = null ) {
                $_SESSION = isset( $data[2] ) ? $data[2] : array();
 
index 15a692d..a772d31 100644 (file)
@@ -3,7 +3,19 @@
  * Parser-related tests that don't suit for parserTests.txt
  */
  
- class ExtraParserTest extends PHPUnit_Framework_TestCase {
+class ExtraParserTest extends PHPUnit_Framework_TestCase {
+
+       function setUp() {
+               global $wgMemc;
+
+               $wgMemc = new FakeMemCachedClient;
+       }
+
+       function tearDown() {
+               global $wgMemc;
+
+               $wgMemc = null;
+       }
 
        // Bug 8689 - Long numeric lines kill the parser
        function testBug8689() {
@@ -15,4 +27,4 @@
                $this->assertEquals( "<p>$longLine</p>", 
                        $parser->parse( $longLine, $t, $options )->getText() );
        }
- }
\ No newline at end of file
+ }
index 7903efd..c37d2f6 100644 (file)
@@ -17,10 +17,11 @@ class LanguageConverterTest extends PHPUnit_Framework_TestCase {
        }
 
        function tearDown() {
-               global $wgMemc;
+               global $wgMemc, $wgContLang;
                unset( $wgMemc );
                unset( $this->lc );
                unset( $this->lang );
+               $wgContLang = null;
        }
 
        function testGetPreferredVariantDefaults() {
index a0bc966..aed2116 100644 (file)
@@ -1,6 +1,13 @@
 <?php
 
 class MessageTest extends PHPUnit_Framework_TestCase {
+
+       function setUp() {
+               global $wgContLanguageCode;
+               
+               $wgContLanguageCode = 'en'; # For mainpage to be 'Main Page'
+       }
+
        function testExists() {
                $this->assertTrue( Message::key( 'mainpage' )->exists() );
                $this->assertTrue( Message::key( 'mainpage' )->params( array() )->exists() );
@@ -30,4 +37,4 @@ class MessageTest extends PHPUnit_Framework_TestCase {
        function testInLanguageThrows() {
                Message::key( 'foo' )->inLanguage( 123 );
        }
-}
\ No newline at end of file
+}
index 370b0c4..e727b65 100644 (file)
@@ -24,6 +24,7 @@ class SearchDbTest extends SearchEngineTest {
                }
                unset( $this->db );
                unset( $this->search );
+               $GLOBALS['wgContLang'] = null;
        }
 }
 
index b3c405c..a4fc357 100644 (file)
@@ -62,7 +62,7 @@ class SearchUpdateTest extends PHPUnit_Framework_TestCase {
        }
 
        function setUp() {
-               global $wgSearchType, $wgDBtype, $wgLBFactoryConf, $wgDBservers;
+               global $wgSearchType, $wgDBtype, $wgLBFactoryConf, $wgDBservers, $wgContLang;
 
                self::$searchType  = $wgSearchType;
                self::$dbtype      = $wgDBtype;
@@ -73,6 +73,7 @@ class SearchUpdateTest extends PHPUnit_Framework_TestCase {
                $wgDBtype = 'mock';
                $wgLBFactoryConf['class'] = 'LBFactory_Simple';
                $wgDBservers = null;
+               $wgContLang = Language::factory( 'en' );
                LBFactory::destroyInstance();
        }
 
@@ -85,6 +86,7 @@ class SearchUpdateTest extends PHPUnit_Framework_TestCase {
                $wgDBtype = self::$dbtype;
                $wgLBFactoryConf = self::$factoryconf;
                $wgDBservers = self::$dbservers;
+               $wgContLang = null;
        }
 
        function testUpdateText() {
index 4d34e6f..f451974 100644 (file)
@@ -10,7 +10,12 @@ class TitlePermissionTest extends PhpUnit_Framework_TestCase {
        static $altUserName;
 
        function setUp() {
-               global $wgLocaltimezone, $wgLocalTZoffset;
+               global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang, $wgMessageCache;
+
+               $wgMemc = new FakeMemCachedClient;
+               $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
+               $wgContLang = $wgLang = Language::factory( 'en' );
+
                self::$userName = "Useruser";
                self::$altUserName = "Altuseruser";
                date_default_timezone_set( $wgLocaltimezone );
@@ -39,6 +44,11 @@ class TitlePermissionTest extends PhpUnit_Framework_TestCase {
                }
        }
 
+       function tearDown() {
+               global $wgMemc, $wgContLang, $wgLang;
+               $wgMemc = $wgContLang = $wgLang = null;
+       }
+
        function setUserPerm( $perm ) {
                if ( is_array( $perm ) ) {
                        self::$user->mRights = $perm;
@@ -638,4 +648,4 @@ class TitlePermissionTest extends PhpUnit_Framework_TestCase {
                #   $user->blockedFor() == ''
                #   $user->mBlock->mExpiry == 'infinity'
        }
-}
\ No newline at end of file
+}
index 059126f..41c9d80 100644 (file)
@@ -7,7 +7,9 @@ class UploadTest extends PHPUnit_Framework_TestCase {
 
 
        function setUp() {
+               global $wgContLang;
                parent::setup();
+               $wgContLang = Language::factory( 'en' );
                $this->upload = new UploadTestHandler;
        }