Merge "Add version number to deprecated setting"
authorSiebrand <siebrand@wikimedia.org>
Tue, 9 Oct 2012 06:30:03 +0000 (06:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 9 Oct 2012 06:30:03 +0000 (06:30 +0000)
148 files changed:
includes/ExternalStoreDB.php
tests/phpunit/MediaWikiLangTestCase.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/ArticleTest.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/CdbTest.php
tests/phpunit/includes/DiffHistoryBlobTest.php
tests/phpunit/includes/EditPageTest.php
tests/phpunit/includes/ExternalStoreTest.php
tests/phpunit/includes/ExtraParserTest.php
tests/phpunit/includes/FauxResponseTest.php
tests/phpunit/includes/GlobalFunctions/GlobalTest.php
tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php
tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php
tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php
tests/phpunit/includes/HtmlTest.php
tests/phpunit/includes/HttpTest.php
tests/phpunit/includes/IPTest.php
tests/phpunit/includes/JsonTest.php
tests/phpunit/includes/LanguageConverterTest.php
tests/phpunit/includes/LinksUpdateTest.php
tests/phpunit/includes/LocalFileTest.php
tests/phpunit/includes/MWFunctionTest.php
tests/phpunit/includes/MWNamespaceTest.php
tests/phpunit/includes/MessageTest.php
tests/phpunit/includes/ParserOptionsTest.php
tests/phpunit/includes/PathRouterTest.php
tests/phpunit/includes/PreferencesTest.php
tests/phpunit/includes/RecentChangeTest.php
tests/phpunit/includes/ResourceLoaderTest.php
tests/phpunit/includes/RevisionStorageTest.php
tests/phpunit/includes/RevisionTest.php
tests/phpunit/includes/SampleTest.php
tests/phpunit/includes/SanitizerTest.php
tests/phpunit/includes/SeleniumConfigurationTest.php
tests/phpunit/includes/SiteConfigurationTest.php
tests/phpunit/includes/TimeAdjustTest.php
tests/phpunit/includes/TimestampTest.php
tests/phpunit/includes/TitleMethodsTest.php
tests/phpunit/includes/TitlePermissionTest.php
tests/phpunit/includes/TitleTest.php
tests/phpunit/includes/UserTest.php
tests/phpunit/includes/WebRequestTest.php
tests/phpunit/includes/WikiPageTest.php
tests/phpunit/includes/XmlSelectTest.php
tests/phpunit/includes/XmlTest.php
tests/phpunit/includes/ZipDirectoryReaderTest.php
tests/phpunit/includes/api/ApiBlockTest.php
tests/phpunit/includes/api/ApiEditPageTest.php
tests/phpunit/includes/api/ApiOptionsTest.php
tests/phpunit/includes/api/ApiPurgeTest.php
tests/phpunit/includes/api/ApiQueryTest.php
tests/phpunit/includes/api/ApiTestCase.php
tests/phpunit/includes/api/ApiTestCaseUpload.php
tests/phpunit/includes/api/ApiWatchTest.php
tests/phpunit/includes/cache/GenderCacheTest.php
tests/phpunit/includes/cache/ProcessCacheLRUTest.php
tests/phpunit/includes/db/DatabaseSQLTest.php
tests/phpunit/includes/db/DatabaseSqliteTest.php
tests/phpunit/includes/db/DatabaseTest.php
tests/phpunit/includes/db/TestORMRowTest.php
tests/phpunit/includes/debug/MWDebugTest.php
tests/phpunit/includes/filerepo/FileBackendTest.php
tests/phpunit/includes/filerepo/StoreBatchTest.php
tests/phpunit/includes/libs/CSSMinTest.php
tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
tests/phpunit/includes/media/BitmapScalingTest.php
tests/phpunit/includes/media/ExifBitmapTest.php
tests/phpunit/includes/media/ExifRotationTest.php
tests/phpunit/includes/media/ExifTest.php
tests/phpunit/includes/media/FormatMetadataTest.php
tests/phpunit/includes/media/GIFMetadataExtractorTest.php
tests/phpunit/includes/media/GIFTest.php
tests/phpunit/includes/media/JpegMetadataExtractorTest.php
tests/phpunit/includes/media/JpegTest.php
tests/phpunit/includes/media/PNGMetadataExtractorTest.php
tests/phpunit/includes/media/PNGTest.php
tests/phpunit/includes/media/SVGMetadataExtractorTest.php
tests/phpunit/includes/media/TiffTest.php
tests/phpunit/includes/media/XMPTest.php
tests/phpunit/includes/media/XMPValidateTest.php
tests/phpunit/includes/mobile/DeviceDetectionTest.php
tests/phpunit/includes/parser/MagicVariableTest.php
tests/phpunit/includes/parser/NewParserTest.php
tests/phpunit/includes/parser/ParserMethodsTest.php
tests/phpunit/includes/parser/ParserPreloadTest.php
tests/phpunit/includes/parser/PreprocessorTest.php
tests/phpunit/includes/search/SearchEngineTest.php
tests/phpunit/includes/search/SearchUpdateTest.php
tests/phpunit/includes/specials/SpecialRecentchangesTest.php
tests/phpunit/includes/specials/SpecialSearchTest.php
tests/phpunit/includes/upload/UploadFromUrlTest.php
tests/phpunit/includes/upload/UploadStashTest.php
tests/phpunit/includes/upload/UploadTest.php
tests/phpunit/languages/LanguageAmTest.php
tests/phpunit/languages/LanguageArTest.php
tests/phpunit/languages/LanguageBeTest.php
tests/phpunit/languages/LanguageBe_taraskTest.php
tests/phpunit/languages/LanguageBhTest.php
tests/phpunit/languages/LanguageBsTest.php
tests/phpunit/languages/LanguageCsTest.php
tests/phpunit/languages/LanguageCuTest.php
tests/phpunit/languages/LanguageCyTest.php
tests/phpunit/languages/LanguageDsbTest.php
tests/phpunit/languages/LanguageFrTest.php
tests/phpunit/languages/LanguageGaTest.php
tests/phpunit/languages/LanguageGdTest.php
tests/phpunit/languages/LanguageGvTest.php
tests/phpunit/languages/LanguageHeTest.php
tests/phpunit/languages/LanguageHiTest.php
tests/phpunit/languages/LanguageHrTest.php
tests/phpunit/languages/LanguageHsbTest.php
tests/phpunit/languages/LanguageHuTest.php
tests/phpunit/languages/LanguageHyTest.php
tests/phpunit/languages/LanguageKshTest.php
tests/phpunit/languages/LanguageLnTest.php
tests/phpunit/languages/LanguageLtTest.php
tests/phpunit/languages/LanguageLvTest.php
tests/phpunit/languages/LanguageMgTest.php
tests/phpunit/languages/LanguageMkTest.php
tests/phpunit/languages/LanguageMlTest.php
tests/phpunit/languages/LanguageMoTest.php
tests/phpunit/languages/LanguageMtTest.php
tests/phpunit/languages/LanguageNlTest.php
tests/phpunit/languages/LanguageNsoTest.php
tests/phpunit/languages/LanguagePlTest.php
tests/phpunit/languages/LanguageRoTest.php
tests/phpunit/languages/LanguageRuTest.php
tests/phpunit/languages/LanguageSeTest.php
tests/phpunit/languages/LanguageSgsTest.php
tests/phpunit/languages/LanguageShTest.php
tests/phpunit/languages/LanguageSkTest.php
tests/phpunit/languages/LanguageSlTest.php
tests/phpunit/languages/LanguageSmaTest.php
tests/phpunit/languages/LanguageSrTest.php
tests/phpunit/languages/LanguageTest.php
tests/phpunit/languages/LanguageTiTest.php
tests/phpunit/languages/LanguageTlTest.php
tests/phpunit/languages/LanguageTrTest.php
tests/phpunit/languages/LanguageUkTest.php
tests/phpunit/languages/LanguageUzTest.php
tests/phpunit/languages/LanguageWaTest.php
tests/phpunit/maintenance/DumpTestCase.php
tests/phpunit/maintenance/backupTextPassTest.php
tests/phpunit/maintenance/backup_PageTest.php
tests/phpunit/skins/SideBarTest.php
tests/phpunit/suites/UploadFromUrlTestSuite.php

index 4f35394..37b1b93 100644 (file)
@@ -100,8 +100,8 @@ class ExternalStoreDB {
         */
        function fetchFromURL( $url ) {
                $path = explode( '/', $url );
-               $cluster  = $path[2];
-               $id       = $path[3];
+               $cluster = $path[2];
+               $id = $path[3];
                if ( isset( $path[4] ) ) {
                        $itemID = $path[4];
                } else {
index 6dd8ea3..3034601 100644 (file)
@@ -4,39 +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;
 
+       protected function setUp() {
+               global $wgLanguageCode, $wgContLang;
                parent::setUp();
 
-               self::$oldLang = $wgLang;
-               self::$oldContLang = $wgContLang;
-
-               if( $wgLanguageCode != $wgContLang->getCode() ) {
+               if ( $wgLanguageCode != $wgContLang->getCode() ) {
                        throw new MWException("Error in MediaWikiLangTestCase::setUp(): " .
                                "\$wgLanguageCode ('$wgLanguageCode') is different from " .
                                "\$wgContLang->getCode() (" . $wgContLang->getCode() . ")" );
                }
 
-               $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
+               $langCode = 'en'; # For mainpage to be 'Main Page'
+               $langObj = Language::factory( $langCode );
 
-               $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
-               MessageCache::singleton()->disable();
-
-       }
+               $this->setMwGlobals( array(
+                       'wgLanguageCode' => $langCode,
+                       'wgLang' => $langObj,
+                       'wgContLang' => $langObj,
+               ) );
 
-       public function tearDown() {
-               global $wgContLang, $wgLang, $wgLanguageCode;
-               $wgLang = self::$oldLang;
-
-               $wgContLang = self::$oldContLang;
-               $wgLanguageCode = $wgContLang->getCode();
-               self::$oldContLang = self::$oldLang = null;
-
-               parent::tearDown();
+               MessageCache::singleton()->disable();
        }
-
 }
index 54a3f7c..6b580a5 100644 (file)
@@ -29,6 +29,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         */
        private $tmpfiles = array();
 
+       /**
+        * Holds original values of MediaWiki configuration settings
+        * to be restored in tearDown().
+        * See also setMwGlobal().
+        * @var array
+        */
+       private $mwGlobals = array();
 
        /**
         * Table name prefixes. Oracle likes it shorter.
@@ -119,6 +126,30 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                return $fname;
        }
 
+       /**
+        * setUp and tearDown should (where significant)
+        * happen in reverse order.
+        */
+       protected function setUp() {
+               parent::setUp();
+
+               // Cleaning up temporary files
+               foreach ( $this->tmpfiles as $fname ) {
+                       if ( is_file( $fname ) || ( is_link( $fname ) ) ) {
+                               unlink( $fname );
+                       } elseif ( is_dir( $fname ) ) {
+                               wfRecursiveRemoveDir( $fname );
+                       }
+               }
+
+               // Clean up open transactions
+               if ( $this->needsDB() && $this->db ) {
+                       while( $this->db->trxLevel() > 0 ) {
+                               $this->db->rollback();
+                       }
+               }
+       }
+
        protected function tearDown() {
                // Cleaning up temporary files
                foreach ( $this->tmpfiles as $fname ) {
@@ -129,16 +160,67 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        }
                }
 
-               // clean up open transactions
-               if( $this->needsDB() && $this->db ) {
+               // Clean up open transactions
+               if ( $this->needsDB() && $this->db ) {
                        while( $this->db->trxLevel() > 0 ) {
                                $this->db->rollback();
                        }
                }
 
+               // Restore mw globals
+               foreach ( $this->mwGlobals as $key => $value ) {
+                       $GLOBALS[$key] = $value;
+               }
+               $this->mwGlobals = array();
+
                parent::tearDown();
        }
 
+       /**
+        * Individual test functions may override globals (either directly or through this
+        * setMwGlobals() function), however one must call this method at least once for
+        * each key within the setUp().
+        * That way the key is added to the array of globals that will be reset afterwards
+        * in the tearDown(). And, equally important, that way all other tests are executed
+        * with the same settings (instead of using the unreliable local settings for most
+        * tests and fix it only for some tests).
+        *
+        * @example
+        * <code>
+        *     protected function setUp() {
+        *         $this->setMwGlobals( 'wgRestrictStuff', true );
+        *     }
+        *
+        *     function testFoo() {}
+        *
+        *     function testBar() {}
+        *         $this->assertTrue( self::getX()->doStuff() );
+        *
+        *         $this->setMwGlobals( 'wgRestrictStuff', false );
+        *         $this->assertTrue( self::getX()->doStuff() );
+        *     }
+        *
+        *     function testQuux() {}
+        * </code>
+        *
+        * @param array|string $pairs Key to the global variable, or an array
+        *  of key/value pairs.
+        * @param mixed $value Value to set the global to (ignored
+        *  if an array is given as first argument).
+        */
+       protected function setMwGlobals( $pairs, $value = null ) {
+               if ( !is_array( $pairs ) ) {
+                       $key = $pairs;
+                       $this->mwGlobals[$key] = $GLOBALS[$key];
+                       $GLOBALS[$key] = $value;
+               } else {
+                       foreach ( $pairs as $key => $value ) {
+                               $this->mwGlobals[$key] = $GLOBALS[$key];
+                               $GLOBALS[$key] = $value;
+                       }
+               }
+       }
+
        function dbPrefix() {
                return $this->db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX;
        }
index 846d2b8..52d9203 100644 (file)
@@ -2,19 +2,25 @@
 
 class ArticleTest extends MediaWikiTestCase {
 
-       private $title; // holds a Title object
-       private $article; // holds an article
+       /**
+        * @var Title
+        */
+       private $title;
+       /**
+        * @var Article
+        */
+       private $article;
 
        /** creates a title object and its article object */
-       function setUp() {
-               $this->title   = Title::makeTitle( NS_MAIN, 'SomePage' );
+       protected function setUp() {
+               $this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
                $this->article = new Article( $this->title );
 
        }
 
        /** cleanup title object and its article object */
-       function tearDown() {
-               $this->title   = null;
+       protected function tearDown() {
+               $this->title = null;
                $this->article = null;
 
        }
index 0c95b8d..5ac05ba 100644 (file)
@@ -11,17 +11,15 @@ class BlockTest extends MediaWikiLangTestCase {
        /* variable used to save up the blockID we insert in this test suite */
        private $blockId;
 
-       function setUp() {
-               global $wgContLang;
+       protected function setUp() {
                parent::setUp();
-               $wgContLang = Language::factory( 'en' );
+               $this->setMwGlobals( 'wgContLang', Language::factory( 'en' ) );
        }
 
        function addDBData() {
-               //$this->dumpBlocks();
 
                $user = User::newFromName( 'UTBlockee' );
-               if( $user->getID() == 0 ) {
+               if ( $user->getID() == 0 ) {
                        $user->addToDatabase();
                        $user->setPassword( 'UTBlockeePassword' );
 
@@ -45,7 +43,7 @@ class BlockTest extends MediaWikiLangTestCase {
                // its value might change depending on the order the tests are run.
                // ApiBlockTest insert its own blocks!
                $newBlockId = $this->block->getId();
-               if ($newBlockId) {
+               if ( $newBlockId ) {
                        $this->blockId = $newBlockId;
                } else {
                        throw new MWException( "Failed to insert block for BlockTest; old leftover block remaining?" );
@@ -88,7 +86,7 @@ class BlockTest extends MediaWikiLangTestCase {
         *
         * This stopped working with r84475 and friends: regression being fixed for bug 29116.
         *
-        * @dataProvider dataBug29116
+        * @dataProvider provideBug29116Data
         */
        function testBug29116LoadWithEmptyIp( $vagueTarget ) {
                $this->hideDeprecated( 'Block::load' );
@@ -108,14 +106,14 @@ class BlockTest extends MediaWikiLangTestCase {
         * because the new function didn't accept empty strings like Block::load()
         * had. Regression bug 29116.
         *
-        * @dataProvider dataBug29116
+        * @dataProvider provideBug29116Data
         */
        function testBug29116NewFromTargetWithEmptyIp( $vagueTarget ) {
                $block = Block::newFromTarget('UTBlockee', $vagueTarget);
                $this->assertTrue( $this->block->equals( $block ), "newFromTarget() returns the same block as the one that was made when given empty vagueTarget param " . var_export( $vagueTarget, true ) );
        }
 
-       function dataBug29116() {
+       public static function provideBug29116Data() {
                return array(
                        array( null ),
                        array( '' ),
index b5418dd..97fffda 100644 (file)
@@ -6,7 +6,7 @@
 
 class CdbTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
                if ( !CdbReader::haveExtension() ) {
                        $this->markTestSkipped( 'Native CDB support is not available' );
                }
index cdb6ed2..d46e683 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 class DiffHistoryBlobTest extends MediaWikiTestCase {
-       function setUp() {
+       protected function setUp() {
                if ( !extension_loaded( 'xdiff' ) ) {
                        $this->markTestSkipped( 'The xdiff extension is not available' );
                        return;
@@ -28,7 +28,7 @@ class DiffHistoryBlobTest extends MediaWikiTestCase {
                        "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
        }
 
-       function provideXdiffAdler32() {
+       public static function provideXdiffAdler32() {
                return array(
                        array( '', 'Empty string' ),
                        array( "\0", 'Null' ),
index 8ecfd7e..eee5f37 100644 (file)
@@ -6,14 +6,14 @@
 class EditPageTest extends MediaWikiTestCase {
 
        /**
-        * @dataProvider dataExtractSectionTitle
+        * @dataProvider provideExtractSectionTitle
         */
        function testExtractSectionTitle( $section, $title ) {
                $extracted = EditPage::extractSectionTitle( $section );
                $this->assertEquals( $title, $extracted );
        }
 
-       function dataExtractSectionTitle() {
+       public static function provideExtractSectionTitle() {
                return array(
                        array(
                                "== Test ==\n\nJust a test section.",
index 92ec734..fe6c60d 100644 (file)
@@ -4,29 +4,78 @@
  */
 
 class ExternalStoreTest extends MediaWikiTestCase {
-       private $saved_wgExternalStores;
 
-       function setUp() {
-               global $wgExternalStores;
-               $this->saved_wgExternalStores = $wgExternalStores ;
-       }
+       function testExternalFetchFromURL() {
+               $this->setMwGlobals( 'wgExternalStores', false );
 
-       function tearDown() {
-               global $wgExternalStores;
-               $wgExternalStores = $this->saved_wgExternalStores ;
-       }
+               $this->assertFalse(
+                       ExternalStore::fetchFromURL( 'FOO://cluster1/200' ),
+                       'Deny if wgExternalStores is not set to a non-empty array'
+               );
 
-       function testExternalStoreDoesNotFetchIncorrectURL() {
-               global $wgExternalStores;
-               $wgExternalStores = true;
+               $this->setMwGlobals( 'wgExternalStores', array( 'FOO' ) );
 
+               $this->assertEquals(
+                       ExternalStore::fetchFromURL( 'FOO://cluster1/200' ),
+                       'Hello',
+                       'Allow FOO://cluster1/200'
+               );
+               $this->assertEquals(
+                       ExternalStore::fetchFromURL( 'FOO://cluster1/300/0' ),
+                       'Hello',
+                       'Allow FOO://cluster1/300/0'
+               );
                # Assertions for r68900
                $this->assertFalse(
-                       ExternalStore::fetchFromURL( 'http://' ) );
+                       ExternalStore::fetchFromURL( 'ftp.example.org' ),
+                       'Deny domain ftp.example.org'
+               );
                $this->assertFalse(
-                       ExternalStore::fetchFromURL( 'ftp.wikimedia.org' ) );
+                       ExternalStore::fetchFromURL( '/example.txt' ),
+                       'Deny path /example.txt'
+               );
                $this->assertFalse(
-                       ExternalStore::fetchFromURL( '/super.txt' ) );
+                       ExternalStore::fetchFromURL( 'http://' ),
+                       'Deny protocol http://'
+               );
        }
 }
 
+class ExternalStoreFOO {
+
+       protected $data = array(
+               'cluster1' => array(
+                       '200' => 'Hello',
+                       '300' => array(
+                               'Hello', 'World',
+                       ),
+               ),
+       );
+
+       /**
+        * Fetch data from given URL
+        * @param $url String: an url of the form FOO://cluster/id or FOO://cluster/id/itemid.
+        * @return mixed
+        */
+       function fetchFromURL( $url ) {
+               // Based on ExternalStoreDB
+               $path = explode( '/', $url );
+               $cluster = $path[2];
+               $id = $path[3];
+               if ( isset( $path[4] ) ) {
+                       $itemID = $path[4];
+               } else {
+                       $itemID = false;
+               }
+
+               if ( !isset( $this->data[$cluster][$id] ) ) {
+                       return null;
+               }
+
+               if ( $itemID !== false && is_array( $this->data[$cluster][$id] ) && isset( $this->data[$cluster][$id][$itemID] ) ) {
+                       return $this->data[$cluster][$id][$itemID];
+               }
+
+               return $this->data[$cluster][$id];
+       }
+}
\ No newline at end of file
index 903a6d2..14bc0bb 100644 (file)
@@ -5,18 +5,18 @@
  */
 class ExtraParserTest extends MediaWikiTestCase {
 
-       function setUp() {
-               global $wgMemc;
-               global $wgContLang;
-               global $wgShowDBErrorBacktrace;
-               global $wgLanguageCode;
-               global $wgAlwaysUseTidy;
+       protected function setUp() {
+               parent::setUp();
 
-               $wgShowDBErrorBacktrace = true;
-               $wgLanguageCode = 'en';
-               $wgContLang = new Language( 'en' );
-               $wgMemc = new EmptyBagOStuff;
-               $wgAlwaysUseTidy = false;
+               $this->setMwGlobals( array(
+                       'wgShowDBErrorBacktrace' => true,
+                       'wgLanguageCode' => 'en',
+                       'wgContLang' => Language::factory( 'en' ),
+                       'wgLang' => Language::factory( 'en' ),
+                       'wgMemc' => new EmptyBagOStuff,
+                       'wgAlwaysUseTidy' => false,
+                       'wgCleanSignatures' => true,
+               ) );
                
                $this->options = new ParserOptions;
                $this->options->setTemplateCallback( array( __CLASS__, 'statelessFetchTemplate' ) );
@@ -27,11 +27,8 @@ class ExtraParserTest extends MediaWikiTestCase {
 
        // Bug 8689 - Long numeric lines kill the parser
        function testBug8689() {
-               global $wgLang;
                global $wgUser;
                $longLine = '1.' . str_repeat( '1234567890', 100000 ) . "\n";
-
-               if ( $wgLang === null ) $wgLang = new Language;
                
                $t = Title::newFromText( 'Unit test' );
                $options = ParserOptions::newFromUser( $wgUser );
@@ -65,14 +62,8 @@ class ExtraParserTest extends MediaWikiTestCase {
         * cleanSig() makes all templates substs and removes tildes
         */
        function testCleanSig() {
-               global $wgCleanSignatures;
-               $oldCleanSignature = $wgCleanSignatures;
-               $wgCleanSignatures = true;
-
                $title = Title::newFromText( __FUNCTION__ );
                $outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
-
-               $wgCleanSignatures = $oldCleanSignature;
                
                $this->assertEquals( "{{SUBST:Foo}} ", $outputText );
        }
@@ -82,13 +73,10 @@ class ExtraParserTest extends MediaWikiTestCase {
         */
        function testCleanSigDisabled() {
                global $wgCleanSignatures;
-               $oldCleanSignature = $wgCleanSignatures;
                $wgCleanSignatures = false;
 
                $title = Title::newFromText( __FUNCTION__ );
                $outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
-
-               $wgCleanSignatures = $oldCleanSignature;
                
                $this->assertEquals( "{{Foo}} ~~~~", $outputText );
        }
@@ -101,7 +89,7 @@ class ExtraParserTest extends MediaWikiTestCase {
                $this->assertEquals( Parser::cleanSigInSig( $in), $out );
        }
        
-       function provideStringsForCleanSigInSig() {
+       public static function provideStringsForCleanSigInSig() {
                return array(
                        array( "{{Foo}} ~~~~", "{{Foo}} " ),
                        array( "~~~", "" ),
index c042004..35c7f8f 100644 (file)
@@ -25,7 +25,7 @@
 class FauxResponseTest extends MediaWikiTestCase {
        var $response;
 
-       function setUp() {
+       protected function setUp() {
                $this->response = new FauxResponse;
        }
 
index 9097d30..4d53d06 100644 (file)
@@ -1,22 +1,32 @@
 <?php
 
 class GlobalTest extends MediaWikiTestCase {
-       function setUp() {
-               global $wgReadOnlyFile, $wgUrlProtocols;
-               $this->originals['wgReadOnlyFile'] = $wgReadOnlyFile;
-               $this->originals['wgUrlProtocols'] = $wgUrlProtocols;
-               $wgReadOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
-               $wgUrlProtocols[] = 'file://';
-               unlink( $wgReadOnlyFile );
+       protected function setUp() {
+               parent::setUp();
+
+               $readOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
+               unlink( $readOnlyFile );
+
+               $this->setMwGlobals( array(
+                       'wgReadOnlyFile' => $readOnlyFile,
+                       'wgUrlProtocols' => array(
+                               'http://',
+                               'https://',
+                               'mailto:',
+                               '//',
+                               'file://', # Non-default
+                       ),
+               ) );
        }
 
-       function tearDown() {
-               global $wgReadOnlyFile, $wgUrlProtocols;
+       protected function tearDown() {
+               global $wgReadOnlyFile;
+
                if ( file_exists( $wgReadOnlyFile ) ) {
                        unlink( $wgReadOnlyFile );
                }
-               $wgReadOnlyFile = $this->originals['wgReadOnlyFile'];
-               $wgUrlProtocols = $this->originals['wgUrlProtocols'];
+
+               parent::tearDown();
        }
 
        /** @dataProvider provideForWfArrayDiff2 */
@@ -27,7 +37,7 @@ class GlobalTest extends MediaWikiTestCase {
        }
 
        // @todo Provide more tests
-       public function provideForWfArrayDiff2() {
+       public static function provideForWfArrayDiff2() {
                // $a $b $expected
                return array(
                        array(
@@ -100,7 +110,7 @@ class GlobalTest extends MediaWikiTestCase {
                $this->assertTrue( $end > $start, "Time is running backwards!" );
        }
 
-       function dataArrayToCGI() {
+       public static function provideArrayToCGI() {
                return array(
                        array( array(), '' ), // empty
                        array( array( 'foo' => 'bar' ), 'foo=bar' ), // string test
@@ -119,7 +129,7 @@ class GlobalTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataArrayToCGI
+        * @dataProvider provideArrayToCGI
         */
        function testArrayToCGI( $array, $result ) {
                $this->assertEquals( $result, wfArrayToCGI( $array ) );
@@ -134,7 +144,7 @@ class GlobalTest extends MediaWikiTestCase {
                                array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
        }
 
-       function dataCgiToArray() {
+       public static function provideCgiToArray() {
                return array(
                        array( '', array() ), // empty
                        array( 'foo=bar', array( 'foo' => 'bar' ) ), // string
@@ -150,13 +160,13 @@ class GlobalTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataCgiToArray
+        * @dataProvider provideCgiToArray
         */
        function testCgiToArray( $cgi, $result ) {
                $this->assertEquals( $result, wfCgiToArray( $cgi ) );
        }
 
-       function dataCgiRoundTrip() {
+       public static function provideCgiRoundTrip() {
                return array(
                        array( '' ),
                        array( 'foo=bar' ),
@@ -170,7 +180,7 @@ class GlobalTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataCgiRoundTrip
+        * @dataProvider provideCgiRoundTrip
         */
        function testCgiRoundTrip( $cgi ) {
                $this->assertEquals( $cgi, wfArrayToCGI( wfCgiToArray( $cgi ) ) );
@@ -437,7 +447,7 @@ class GlobalTest extends MediaWikiTestCase {
        }
 
        /** array( shorthand, expected integer ) */
-       public function provideShorthand() {
+       public static function provideShorthand() {
                return array(
                        # Null, empty ... 
                        array(     '', -1),
index be6c99e..bed435a 100644 (file)
@@ -19,7 +19,7 @@ class wfAssembleUrl extends MediaWikiTestCase {
         *
         * @return array
         */
-       public function provideURLParts() {
+       public static function provideURLParts() {
                $schemes = array(
                        '' => array(),
                        '//' => array(
index 8867cd5..cb6e6c4 100644 (file)
@@ -32,7 +32,7 @@ class wfExpandUrl extends MediaWikiTestCase {
         *
         * @return array
         */
-       public function provideExpandableUrls() {
+       public static function provideExpandableUrls() {
                $modes = array( 'http', 'https' );
                $servers = array(
                        'http' => 'http://example.com',
index 1cf0e0f..af784bd 100644 (file)
@@ -18,7 +18,7 @@ class wfRemoveDotSegments extends MediaWikiTestCase {
         *
         * @return array
         */
-       public function providePaths() {
+       public static function providePaths() {
                return array(
                        array( '/a/b/c/./../../g', '/a/g' ),
                        array( 'mid/content=5/../6', 'mid/6' ),
index cd1a8db..673702e 100644 (file)
@@ -85,7 +85,7 @@ class wfUrlencodeTest extends MediaWikiTestCase {
         * If you want to add other HTTP server name, you will have to add a new
         * testing method much like the testEncodingUrlWith() method above. 
         */
-       public function provideURLS() {
+       public static function provideURLS() {
                return array(
                ### RFC 1738 chars      
                        // + is not safe
index 05dea35..95a6cb0 100644 (file)
@@ -2,29 +2,17 @@
 /** tests for includes/Html.php */
 
 class HtmlTest extends MediaWikiTestCase {
-       private static $oldLang;
-       private static $oldContLang;
-       private static $oldLanguageCode;
-       private static $oldNamespaces;
-       private static $oldHTML5;
 
-       public function setUp() {
-               global $wgLang, $wgContLang, $wgLanguageCode, $wgHtml5;
+       protected function setUp() {
+               parent::setUp();
 
-               // Save globals
-               self::$oldLang = $wgLang;
-               self::$oldContLang = $wgContLang;
-               self::$oldNamespaces = $wgContLang->getNamespaces();
-               self::$oldLanguageCode = $wgLanguageCode;
-               self::$oldHTML5 = $wgHtml5;
-
-               $wgLanguageCode = 'en';
-               $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
+               $langCode = 'en';
+               $langObj = Language::factory( $langCode );
 
                // Hardcode namespaces during test runs,
                // so that html output based on existing namespaces
                // can be properly evaluated.
-               $wgContLang->setNamespaces( array(
+               $langObj->setNamespaces( array(
                        -2 => 'Media',
                        -1 => 'Special',
                        0  => '',
@@ -44,77 +32,102 @@ class HtmlTest extends MediaWikiTestCase {
                        100  => 'Custom',
                        101  => 'Custom_talk',
                ) );
+
+               $this->setMwGlobals( array(
+                       'wgLanguageCode' => $langCode,
+                       'wgContLang' => $langObj,
+                       'wgLang' => $langObj,
+                       'wgHtml5' => true,
+                       'wgWellFormedXml' => false,
+               ) );
        }
 
-       public function tearDown() {
-               global $wgLang, $wgContLang, $wgLanguageCode, $wgHtml5;
+       public function testElementBasics() {
+               global $wgWellFormedXml;
 
-               // Restore globals
-               $wgContLang->setNamespaces( self::$oldNamespaces );
-               $wgLang = self::$oldLang;
-               $wgContLang = self::$oldContLang;
-               $wgLanguageCode = self::$oldLanguageCode;
-               $wgHtml5 = self::$oldHTML5;
-       }
+               $this->assertEquals(
+                       '<img>',
+                       Html::element( 'img', null, '' ),
+                       'No close tag for short-tag elements'
+               );
 
-       /**
-        * Wrapper to easily set $wgHtml5 = true.
-        * Original value will be restored after test completion.
-        * @todo Move to MediaWikiTestCase
-        */
-       public function enableHTML5() {
-               global $wgHtml5;
-               $wgHtml5 = true;
-       }
-       /**
-        * Wrapper to easily set $wgHtml5 = false
-        * Original value will be restored after test completion.
-        * @todo Move to MediaWikiTestCase
-        */
-       public function disableHTML5() {
-               global $wgHtml5;
-               $wgHtml5 = false;
+               $this->assertEquals(
+                       '<element></element>',
+                       Html::element( 'element', null, null ),
+                       'Close tag for empty element (null, null)'
+               );
+
+               $this->assertEquals(
+                       '<element></element>',
+                       Html::element( 'element', array(), '' ),
+                       'Close tag for empty element (array, string)'
+               );
+
+               $wgWellFormedXml = true;
+
+               $this->assertEquals(
+                       '<img />',
+                       Html::element( 'img', null, '' ),
+                       'Self-closing tag for short-tag elements (wgWellFormedXml = true)'
+               );
        }
 
        public function testExpandAttributesSkipsNullAndFalse() {
                
                ### EMPTY ########
-               $this->AssertEmpty(
+               $this->assertEmpty(
                        Html::expandAttributes( array( 'foo' => null ) ),
                        'skip keys with null value'
                );
-               $this->AssertEmpty(
+               $this->assertEmpty(
                        Html::expandAttributes( array( 'foo' => false ) ),
                        'skip keys with false value'
                );
-               $this->AssertNotEmpty(
+               $this->assertNotEmpty(
                        Html::expandAttributes( array( 'foo' => '' ) ),
                        'keep keys with an empty string'
                );
        }
 
        public function testExpandAttributesForBooleans() {
-               global $wgHtml5;
-               $this->AssertEquals(
+               global $wgHtml5, $wgWellFormedXml;
+
+               $this->assertEquals(
                        '',
                        Html::expandAttributes( array( 'selected' => false ) ),
                        'Boolean attributes do not generates output when value is false'
                );
-               $this->AssertEquals(
+               $this->assertEquals(
                        '',
                        Html::expandAttributes( array( 'selected' => null ) ),
                        'Boolean attributes do not generates output when value is null'
                );
 
-               $this->AssertEquals(
-                       $wgHtml5 ? ' selected=""' : ' selected="selected"',
+               $this->assertEquals(
+                       ' selected',
                        Html::expandAttributes( array( 'selected' => true ) ),
-                       'Boolean attributes skip value output'
+                       'Boolean attributes have no value when value is true'
                );
-               $this->AssertEquals(
-                       $wgHtml5 ? ' selected=""' : ' selected="selected"',
+               $this->assertEquals(
+                       ' selected',
                        Html::expandAttributes( array( 'selected' ) ),
-                       'Boolean attributes (ex: selected) do not need a value'
+                       'Boolean attributes have no value when value is true (passed as numerical array)'
+               );
+
+               $wgWellFormedXml = true;
+
+               $this->assertEquals(
+                       ' selected=""',
+                       Html::expandAttributes( array( 'selected' => true ) ),
+                       'Boolean attributes have empty string value when value is true (wgWellFormedXml)'
+               );
+
+               $wgHtml5 = false;
+
+               $this->assertEquals(
+                       ' selected="selected"',
+                       Html::expandAttributes( array( 'selected' => true ) ),
+                       'Boolean attributes have their key as value when value is true (wgWellFormedXml, wgHTML5 = false)'
                );
        }
 
@@ -123,26 +136,51 @@ class HtmlTest extends MediaWikiTestCase {
         * Please note it output a string prefixed with a space!
         */
        public function testExpandAttributesVariousExpansions() {
+               global $wgWellFormedXml;
+
                ### NOT EMPTY ####
-               $this->AssertEquals(
+               $this->assertEquals(
+                       ' empty_string=""',
+                       Html::expandAttributes( array( 'empty_string' => '' ) ),
+                       'Empty string is always quoted'
+               );
+               $this->assertEquals(
+                       ' key=value',
+                       Html::expandAttributes( array( 'key' => 'value' ) ),
+                       'Simple string value needs no quotes'
+               );
+               $this->assertEquals(
+                       ' one=1',
+                       Html::expandAttributes( array( 'one' => 1 ) ),
+                       'Number 1 value needs no quotes'
+               );
+               $this->assertEquals(
+                       ' zero=0',
+                       Html::expandAttributes( array( 'zero' => 0 ) ),
+                       'Number 0 value needs no quotes'
+               );
+
+               $wgWellFormedXml = true;
+
+               $this->assertEquals(
                        ' empty_string=""',
                        Html::expandAttributes( array( 'empty_string' => '' ) ),
-                       'Value with an empty string'
+                       'Attribtue values are always quoted (wgWellFormedXml): Empty string'
                );
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' key="value"',
                        Html::expandAttributes( array( 'key' => 'value' ) ),
-                       'Value is a string'
+                       'Attribtue values are always quoted (wgWellFormedXml): Simple string'
                );
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' one="1"',
                        Html::expandAttributes( array( 'one' => 1 ) ),
-                       'Value is a numeric one'
+                       'Attribtue values are always quoted (wgWellFormedXml): Number 1'
                );
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' zero="0"',
                        Html::expandAttributes( array( 'zero' => 0 ) ),
-                       'Value is a numeric zero'
+                       'Attribtue values are always quoted (wgWellFormedXml): Number 0'
                );
        }
 
@@ -153,29 +191,29 @@ class HtmlTest extends MediaWikiTestCase {
         */
        public function testExpandAttributesListValueAttributes() {
                ### STRING VALUES
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' class="redundant spaces here"',
                        Html::expandAttributes( array( 'class' => ' redundant  spaces  here  ' ) ),
                        'Normalization should strip redundant spaces'
                );
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' class="foo bar"',
                        Html::expandAttributes( array( 'class' => 'foo bar foo bar bar' ) ),
                        'Normalization should remove duplicates in string-lists'
                );
                ### "EMPTY" ARRAY VALUES
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' class=""',
                        Html::expandAttributes( array( 'class' => array() ) ),
                        'Value with an empty array'
                );
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' class=""',
                        Html::expandAttributes( array( 'class' => array( null, '', ' ', '  ' ) ) ),
                        'Array with null, empty string and spaces'
                );
                ### NON-EMPTY ARRAY VALUES
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' class="foo bar"',
                        Html::expandAttributes( array( 'class' => array(
                                'foo',
@@ -186,7 +224,7 @@ class HtmlTest extends MediaWikiTestCase {
                        ) ) ),
                        'Normalization should remove duplicates in the array'
                );
-               $this->AssertEquals(
+               $this->assertEquals(
                        ' class="foo bar"',
                        Html::expandAttributes( array( 'class' => array(
                                'foo bar',
@@ -239,48 +277,48 @@ class HtmlTest extends MediaWikiTestCase {
 
        function testNamespaceSelector() {
                $this->assertEquals(
-                       '<select id="namespace" name="namespace">' . "\n" .
-'<option value="0">(Main)</option>' . "\n" .
-'<option value="1">Talk</option>' . "\n" .
-'<option value="2">User</option>' . "\n" .
-'<option value="3">User talk</option>' . "\n" .
-'<option value="4">MyWiki</option>' . "\n" .
-'<option value="5">MyWiki Talk</option>' . "\n" .
-'<option value="6">File</option>' . "\n" .
-'<option value="7">File talk</option>' . "\n" .
-'<option value="8">MediaWiki</option>' . "\n" .
-'<option value="9">MediaWiki talk</option>' . "\n" .
-'<option value="10">Template</option>' . "\n" .
-'<option value="11">Template talk</option>' . "\n" .
-'<option value="14">Category</option>' . "\n" .
-'<option value="15">Category talk</option>' . "\n" .
-'<option value="100">Custom</option>' . "\n" .
-'<option value="101">Custom talk</option>' . "\n" .
+                       '<select id=namespace name=namespace>' . "\n" .
+'<option value=0>(Main)</option>' . "\n" .
+'<option value=1>Talk</option>' . "\n" .
+'<option value=2>User</option>' . "\n" .
+'<option value=3>User talk</option>' . "\n" .
+'<option value=4>MyWiki</option>' . "\n" .
+'<option value=5>MyWiki Talk</option>' . "\n" .
+'<option value=6>File</option>' . "\n" .
+'<option value=7>File talk</option>' . "\n" .
+'<option value=8>MediaWiki</option>' . "\n" .
+'<option value=9>MediaWiki talk</option>' . "\n" .
+'<option value=10>Template</option>' . "\n" .
+'<option value=11>Template talk</option>' . "\n" .
+'<option value=14>Category</option>' . "\n" .
+'<option value=15>Category talk</option>' . "\n" .
+'<option value=100>Custom</option>' . "\n" .
+'<option value=101>Custom talk</option>' . "\n" .
 '</select>',
                        Html::namespaceSelector(),
                        'Basic namespace selector without custom options'
                );
 
                $this->assertEquals(
-                       '<label for="mw-test-namespace">Select a namespace:</label>&#160;' .
-'<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
-'<option value="all">all</option>' . "\n" .
-'<option value="0">(Main)</option>' . "\n" .
-'<option value="1">Talk</option>' . "\n" .
-'<option value="2" selected="">User</option>' . "\n" .
-'<option value="3">User talk</option>' . "\n" .
-'<option value="4">MyWiki</option>' . "\n" .
-'<option value="5">MyWiki Talk</option>' . "\n" .
-'<option value="6">File</option>' . "\n" .
-'<option value="7">File talk</option>' . "\n" .
-'<option value="8">MediaWiki</option>' . "\n" .
-'<option value="9">MediaWiki talk</option>' . "\n" .
-'<option value="10">Template</option>' . "\n" .
-'<option value="11">Template talk</option>' . "\n" .
-'<option value="14">Category</option>' . "\n" .
-'<option value="15">Category talk</option>' . "\n" .
-'<option value="100">Custom</option>' . "\n" .
-'<option value="101">Custom talk</option>' . "\n" .
+                       '<label for=mw-test-namespace>Select a namespace:</label>&#160;' .
+'<select id=mw-test-namespace name=wpNamespace>' . "\n" .
+'<option value=all>all</option>' . "\n" .
+'<option value=0>(Main)</option>' . "\n" .
+'<option value=1>Talk</option>' . "\n" .
+'<option value=2 selected>User</option>' . "\n" .
+'<option value=3>User talk</option>' . "\n" .
+'<option value=4>MyWiki</option>' . "\n" .
+'<option value=5>MyWiki Talk</option>' . "\n" .
+'<option value=6>File</option>' . "\n" .
+'<option value=7>File talk</option>' . "\n" .
+'<option value=8>MediaWiki</option>' . "\n" .
+'<option value=9>MediaWiki talk</option>' . "\n" .
+'<option value=10>Template</option>' . "\n" .
+'<option value=11>Template talk</option>' . "\n" .
+'<option value=14>Category</option>' . "\n" .
+'<option value=15>Category talk</option>' . "\n" .
+'<option value=100>Custom</option>' . "\n" .
+'<option value=101>Custom talk</option>' . "\n" .
 '</select>',
                        Html::namespaceSelector(
                                array( 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ),
@@ -290,24 +328,24 @@ class HtmlTest extends MediaWikiTestCase {
                );
 
                $this->assertEquals(
-                       '<label for="namespace">Select a namespace:</label>&#160;' .
-'<select id="namespace" name="namespace">' . "\n" .
-'<option value="0">(Main)</option>' . "\n" .
-'<option value="1">Talk</option>' . "\n" .
-'<option value="2">User</option>' . "\n" .
-'<option value="3">User talk</option>' . "\n" .
-'<option value="4">MyWiki</option>' . "\n" .
-'<option value="5">MyWiki Talk</option>' . "\n" .
-'<option value="6">File</option>' . "\n" .
-'<option value="7">File talk</option>' . "\n" .
-'<option value="8">MediaWiki</option>' . "\n" .
-'<option value="9">MediaWiki talk</option>' . "\n" .
-'<option value="10">Template</option>' . "\n" .
-'<option value="11">Template talk</option>' . "\n" .
-'<option value="14">Category</option>' . "\n" .
-'<option value="15">Category talk</option>' . "\n" .
-'<option value="100">Custom</option>' . "\n" .
-'<option value="101">Custom talk</option>' . "\n" .
+                       '<label for=namespace>Select a namespace:</label>&#160;' .
+'<select id=namespace name=namespace>' . "\n" .
+'<option value=0>(Main)</option>' . "\n" .
+'<option value=1>Talk</option>' . "\n" .
+'<option value=2>User</option>' . "\n" .
+'<option value=3>User talk</option>' . "\n" .
+'<option value=4>MyWiki</option>' . "\n" .
+'<option value=5>MyWiki Talk</option>' . "\n" .
+'<option value=6>File</option>' . "\n" .
+'<option value=7>File talk</option>' . "\n" .
+'<option value=8>MediaWiki</option>' . "\n" .
+'<option value=9>MediaWiki talk</option>' . "\n" .
+'<option value=10>Template</option>' . "\n" .
+'<option value=11>Template talk</option>' . "\n" .
+'<option value=14>Category</option>' . "\n" .
+'<option value=15>Category talk</option>' . "\n" .
+'<option value=100>Custom</option>' . "\n" .
+'<option value=101>Custom talk</option>' . "\n" .
 '</select>',
                        Html::namespaceSelector(
                                array( 'label' => 'Select a namespace:' )
@@ -318,18 +356,18 @@ class HtmlTest extends MediaWikiTestCase {
 
        function testCanFilterOutNamespaces() {
                $this->assertEquals(
-'<select id="namespace" name="namespace">' . "\n" .
-'<option value="2">User</option>' . "\n" .
-'<option value="4">MyWiki</option>' . "\n" .
-'<option value="5">MyWiki Talk</option>' . "\n" .
-'<option value="6">File</option>' . "\n" .
-'<option value="7">File talk</option>' . "\n" .
-'<option value="8">MediaWiki</option>' . "\n" .
-'<option value="9">MediaWiki talk</option>' . "\n" .
-'<option value="10">Template</option>' . "\n" .
-'<option value="11">Template talk</option>' . "\n" .
-'<option value="14">Category</option>' . "\n" .
-'<option value="15">Category talk</option>' . "\n" .
+'<select id=namespace name=namespace>' . "\n" .
+'<option value=2>User</option>' . "\n" .
+'<option value=4>MyWiki</option>' . "\n" .
+'<option value=5>MyWiki Talk</option>' . "\n" .
+'<option value=6>File</option>' . "\n" .
+'<option value=7>File talk</option>' . "\n" .
+'<option value=8>MediaWiki</option>' . "\n" .
+'<option value=9>MediaWiki talk</option>' . "\n" .
+'<option value=10>Template</option>' . "\n" .
+'<option value=11>Template talk</option>' . "\n" .
+'<option value=14>Category</option>' . "\n" .
+'<option value=15>Category talk</option>' . "\n" .
 '</select>',
                        Html::namespaceSelector(
                                array( 'exclude' => array( 0, 1, 3, 100, 101 ) )
@@ -340,23 +378,23 @@ class HtmlTest extends MediaWikiTestCase {
 
        function testCanDisableANamespaces() {
                $this->assertEquals(
-'<select id="namespace" name="namespace">' . "\n" .
-'<option disabled="" value="0">(Main)</option>' . "\n" .
-'<option disabled="" value="1">Talk</option>' . "\n" .
-'<option disabled="" value="2">User</option>' . "\n" .
-'<option disabled="" value="3">User talk</option>' . "\n" .
-'<option disabled="" value="4">MyWiki</option>' . "\n" .
-'<option value="5">MyWiki Talk</option>' . "\n" .
-'<option value="6">File</option>' . "\n" .
-'<option value="7">File talk</option>' . "\n" .
-'<option value="8">MediaWiki</option>' . "\n" .
-'<option value="9">MediaWiki talk</option>' . "\n" .
-'<option value="10">Template</option>' . "\n" .
-'<option value="11">Template talk</option>' . "\n" .
-'<option value="14">Category</option>' . "\n" .
-'<option value="15">Category talk</option>' . "\n" .
-'<option value="100">Custom</option>' . "\n" .
-'<option value="101">Custom talk</option>' . "\n" .
+'<select id=namespace name=namespace>' . "\n" .
+'<option disabled value=0>(Main)</option>' . "\n" .
+'<option disabled value=1>Talk</option>' . "\n" .
+'<option disabled value=2>User</option>' . "\n" .
+'<option disabled value=3>User talk</option>' . "\n" .
+'<option disabled value=4>MyWiki</option>' . "\n" .
+'<option value=5>MyWiki Talk</option>' . "\n" .
+'<option value=6>File</option>' . "\n" .
+'<option value=7>File talk</option>' . "\n" .
+'<option value=8>MediaWiki</option>' . "\n" .
+'<option value=9>MediaWiki talk</option>' . "\n" .
+'<option value=10>Template</option>' . "\n" .
+'<option value=11>Template talk</option>' . "\n" .
+'<option value=14>Category</option>' . "\n" .
+'<option value=15>Category talk</option>' . "\n" .
+'<option value=100>Custom</option>' . "\n" .
+'<option value=101>Custom talk</option>' . "\n" .
 '</select>',
                        Html::namespaceSelector( array(
                                'disable' => array( 0, 1, 2, 3, 4 )
@@ -366,12 +404,11 @@ class HtmlTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider providesHtml5InputTypes
+        * @dataProvider provideHtml5InputTypes
         */
        function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
-               $this->enableHTML5();
                $this->assertEquals(
-                       '<input type="' . $HTML5InputType . '" />',
+                       '<input type=' . $HTML5InputType . '>',
                        Html::element( 'input', array( 'type' => $HTML5InputType ) ),
                        'In HTML5, HTML::element() should accept type="' . $HTML5InputType . '"'
                );
@@ -381,7 +418,7 @@ class HtmlTest extends MediaWikiTestCase {
         * List of input element types values introduced by HTML5
         * Full list at http://www.w3.org/TR/html-markup/input.html
         */
-       function providesHtml5InputTypes() {
+       function provideHtml5InputTypes() {
                $types = array(
                        'datetime',
                        'datetime-local',
@@ -409,19 +446,18 @@ class HtmlTest extends MediaWikiTestCase {
         * @cover Html::dropDefaults
         * @dataProvider provideElementsWithAttributesHavingDefaultValues
         */
-       function testDropDefaults( $expected, $element, $message = '' ) {
-               $this->enableHTML5();
-               $this->assertEquals( $expected, $element, $message );
+       function testDropDefaults( $expected, $element, $attribs, $message = '' ) {
+               $this->assertEquals( $expected, Html::element( $element, $attribs ), $message );
        }
 
-       function provideElementsWithAttributesHavingDefaultValues() {
+       public static function provideElementsWithAttributesHavingDefaultValues() {
                # Use cases in a concise format:
                # <expected>, <element name>, <array of attributes> [, <message>]
                # Will be mapped to Html::element()
                $cases = array();
 
                ### Generic cases, match $attribDefault static array
-               $cases[] = array( '<area />',
+               $cases[] = array( '<area>',
                        'area', array( 'shape' => 'rect' )
                );
 
@@ -449,7 +485,7 @@ class HtmlTest extends MediaWikiTestCase {
                        'canvas', array( 'width' => 300 )
                );
 
-               $cases[] = array( '<command />',
+               $cases[] = array( '<command>',
                        'command', array( 'type' => 'command' )
                );
 
@@ -463,18 +499,18 @@ class HtmlTest extends MediaWikiTestCase {
                        'form', array( 'enctype' => 'application/x-www-form-urlencoded' )
                );
 
-               $cases[] = array( '<input />',
+               $cases[] = array( '<input>',
                        'input', array( 'formaction' => 'GET' )
                );
-               $cases[] = array( '<input />',
+               $cases[] = array( '<input>',
                        'input', array( 'type' => 'text' )
                );
 
-               $cases[] = array( '<keygen />',
+               $cases[] = array( '<keygen>',
                        'keygen', array( 'keytype' => 'rsa' )
                );
 
-               $cases[] = array( '<link />',
+               $cases[] = array( '<link>',
                        'link', array( 'media' => 'all' )
                );
 
@@ -499,37 +535,37 @@ class HtmlTest extends MediaWikiTestCase {
 
                ### SPECIFIC CASES
 
-               # <link type="text/css" />
-               $cases[] = array( '<link />',
+               # <link type="text/css">
+               $cases[] = array( '<link>',
                        'link', array( 'type' => 'text/css' )
                );
 
-               # <input /> specific handling
-               $cases[] = array( '<input type="checkbox" />',
+               # <input> specific handling
+               $cases[] = array( '<input type=checkbox>',
                        'input', array( 'type' => 'checkbox', 'value' => 'on' ),
                        'Default value "on" is stripped of checkboxes',
                );
-               $cases[] = array( '<input type="radio" />',
+               $cases[] = array( '<input type=radio>',
                        'input', array( 'type' => 'radio', 'value' => 'on' ),
                        'Default value "on" is stripped of radio buttons',
                );
-               $cases[] = array( '<input type="submit" value="Submit" />',
+               $cases[] = array( '<input type=submit value=Submit>',
                        'input', array( 'type' => 'submit', 'value' => 'Submit' ),
                        'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
                );
-               $cases[] = array( '<input type="color" />',
+               $cases[] = array( '<input type=color>',
                        'input', array( 'type' => 'color', 'value' => '' ),
                );
-               $cases[] = array( '<input type="range" />',
+               $cases[] = array( '<input type=range>',
                        'input', array( 'type' => 'range', 'value' => '' ),
                );
 
-               # <select /> specifc handling
-               $cases[] = array( '<select multiple=""></select>',
+               # <select> specifc handling
+               $cases[] = array( '<select multiple></select>',
                        'select', array( 'size' => '4', 'multiple' => true ),
                );
                # .. with numeric value
-               $cases[] = array( '<select multiple=""></select>',
+               $cases[] = array( '<select multiple></select>',
                        'select', array( 'size' => 4, 'multiple' => true ),
                );
                $cases[] = array( '<select></select>',
@@ -553,13 +589,13 @@ class HtmlTest extends MediaWikiTestCase {
                        "dropDefaults accepts values given as an array"
                );
 
-
                # Craft the Html elements
                $ret = array();
                foreach( $cases as $case ) {
                        $ret[] = array(
                                $case[0],
-                               Html::element( $case[1], $case[2] )
+                               $case[1], $case[2],
+                               isset( $case[3] ) ? $case[3] : ''
                        );
                }
                return $ret;
index 263383f..155bd31 100644 (file)
@@ -17,7 +17,7 @@ class HttpTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $ok, $msg );
        }
 
-       function cookieDomains() {
+       public static function cookieDomains() {
                return array(
                        array( false, "org"),
                        array( false, ".org"),
@@ -62,7 +62,7 @@ class HttpTest extends MediaWikiTestCase {
        /**
         * Feeds URI to test a long regular expression in Http::isValidURI
         */
-       function provideURI() {
+       public static function provideURI() {
                /** Format: 'boolean expectation', 'URI to test', 'Optional message' */
                return array(
                        array( false, '¿non sens before!! http://a', 'Allow anything before URI' ),
@@ -131,6 +131,10 @@ class HttpTest extends MediaWikiTestCase {
         * handles header reporting on redirect pages, and will need to be
         * rewritten when bug 29232 is taken care of (high-level handling of
         * HTTP redirects).
+        * @group Broken
+        *  MWHttpRequestTester's constructor is private, needs to use
+        *  MWHttpRequestTester::factory instead. However the objects coming
+        *  from that won't have MWHttpRequestTester::setRespHeaders...
         */
        function testRelativeRedirections() {
                $h = new MWHttpRequestTester( 'http://oldsite/file.ext' );
index f50b2fe..c4a6c55 100644 (file)
@@ -405,7 +405,7 @@ class IPTest extends MediaWikiTestCase {
        }
 
        /** Provider for testIPIsInRange() */
-       function provideIPsAndRanges() {
+       public static function provideIPsAndRanges() {
                        # Format: (expected boolean, address, range, optional message)
                return array(
                        # IPv4
@@ -443,7 +443,7 @@ class IPTest extends MediaWikiTestCase {
        /**
         * Provider for IP::splitHostAndPort()
         */
-       function provideSplitHostAndPort() {
+       public static function provideSplitHostAndPort() {
                return array(
                        array( false, '[', 'Unclosed square bracket' ),
                        array( false, '[::', 'Unclosed square bracket 2' ),
@@ -474,7 +474,7 @@ class IPTest extends MediaWikiTestCase {
        /**
         * Provider for IP::combineHostAndPort()
         */
-       function provideCombineHostAndPort() {
+       public static function provideCombineHostAndPort() {
                return array(
                        array( '[::1]', array( '::1', 2, 2 ), 'IPv6 default port' ),
                        array( '[::1]:2', array( '::1', 2, 3 ), 'IPv6 non-default port' ),
@@ -494,7 +494,7 @@ class IPTest extends MediaWikiTestCase {
        /**
         * Provider for IP::testSanitizeRange()
         */
-       function provideIPCIDRs() {
+       public static function provideIPCIDRs() {
                return array(
                        array( '35.56.31.252/16', '35.56.0.0/16', 'IPv4 range' ),
                        array( '135.16.21.252/24', '135.16.21.0/24', 'IPv4 range' ),
@@ -518,7 +518,7 @@ class IPTest extends MediaWikiTestCase {
        /**
         * Provider for IP::testPrettifyIP()
         */
-       function provideIPsToPrettify() {
+       public static function provideIPsToPrettify() {
                return array(
                        array( '0:0:0:0:0:0:0:0', '::' ),
                        array( '0:0:0::0:0:0', '::' ),
index 75dd18d..9b508f7 100644 (file)
@@ -3,31 +3,25 @@
 class JsonTest extends MediaWikiTestCase {
        
        function testPhpBug46944Test() {
-               
                $this->assertNotEquals( 
                        '\ud840\udc00',                 
                        strtolower( FormatJson::encode( "\xf0\xa0\x80\x80" ) ),
                        'Test encoding an broken json_encode character (U+20000)'
                );
-               
-               
+
        }
        
        function testDecodeVarTypes() {
-               
                $this->assertInternalType( 
                        'object',                       
                        FormatJson::decode( '{"Name": "Cheeso", "Rank": 7}' ),
                        'Default to object'
                );
-               
+
                $this->assertInternalType( 
                        'array',                        
                        FormatJson::decode( '{"Name": "Cheeso", "Rank": 7}', true ),
                        'Optional array'
                );
-               
        }
-       
 }
-
index baf28b0..9fc6f4d 100644 (file)
@@ -4,24 +4,28 @@ class LanguageConverterTest extends MediaWikiLangTestCase {
        protected $lang = null;
        protected $lc = null;
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
-               global $wgMemc, $wgRequest, $wgUser, $wgContLang;
 
-               $wgUser = new User;
-               $wgRequest = new FauxRequest( array() );
-               $wgMemc = new EmptyBagOStuff;
-               $wgContLang = Language::factory( 'tg' );
+               $this->setMwGlobals( array(
+                       'wgContLang' => Language::factory( 'tg' ),
+                       'wgDefaultLanguageVariant' => false,
+                       'wgMemc' => new EmptyBagOStuff,
+                       'wgRequest' => new FauxRequest( array() ),
+                       'wgUser' => new User,
+               ) );
+
                $this->lang = new LanguageToTest();
-               $this->lc = new TestConverter( $this->lang, 'tg',
-                                                                          array( 'tg', 'tg-latn' ) );
+               $this->lc = new TestConverter(
+                       $this->lang, 'tg',
+                       array( 'tg', 'tg-latn' )
+               );
        }
 
-       function tearDown() {
-               global $wgMemc;
-               unset( $wgMemc );
+       protected function tearDown() {
                unset( $this->lc );
                unset( $this->lang );
+
                parent::tearDown();
        }
 
@@ -71,7 +75,7 @@ class LanguageConverterTest extends MediaWikiLangTestCase {
        }
 
        function testGetPreferredVariantHeaderUserVsUrl() {
-               global $wgRequest, $wgUser, $wgContLang;
+               global $wgContLang, $wgRequest, $wgUser;
 
                $wgContLang = Language::factory( 'tg-latn' );
                $wgRequest->setVal( 'variant', 'tg' );
index 8e37b13..40bba7e 100644 (file)
@@ -25,7 +25,7 @@ class LinksUpdateTest extends MediaWikiTestCase {
                );
        }
 
-       function setUp() {
+       protected function setUp() {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->replace(
                        'interwiki',
index 5b26b89..c5a9dc1 100644 (file)
@@ -6,10 +6,11 @@
  */
 
 class LocalFileTest extends MediaWikiTestCase {
-       function setUp() {
-               global $wgCapitalLinks;
 
-               $wgCapitalLinks = true;
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( 'wgCapitalLinks', true );
 
                $info = array(
                        'name'            => 'test',
index ed5e760..f7be59f 100644 (file)
@@ -3,7 +3,6 @@
 class MWFunctionTest extends MediaWikiTestCase {
        
        function testCallUserFuncWorkarounds() {
-               
                $this->assertEquals( 
                        call_user_func( array( 'MWFunctionTest', 'someMethod' ) ),
                        MWFunction::call( 'MWFunctionTest::someMethod' )
@@ -12,9 +11,7 @@ class MWFunctionTest extends MediaWikiTestCase {
                        call_user_func( array( 'MWFunctionTest', 'someMethod' ), 'foo', 'bar', 'baz' ),
                        MWFunction::call( 'MWFunctionTest::someMethod', 'foo', 'bar', 'baz' )
                );
-               
-               
-               
+
                $this->assertEquals( 
                        call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array() ),
                        MWFunction::callArray( 'MWFunctionTest::someMethod', array() )
@@ -23,38 +20,33 @@ class MWFunctionTest extends MediaWikiTestCase {
                        call_user_func_array( array( 'MWFunctionTest', 'someMethod' ), array( 'foo', 'bar', 'baz' ) ),
                        MWFunction::callArray( 'MWFunctionTest::someMethod', array( 'foo', 'bar', 'baz' ) )
                );
-               
        }
        
        function testNewObjFunction() {
-               
                $arg1 = 'Foo';
                $arg2 = 'Bar';
                $arg3 = array( 'Baz' );
                $arg4 = new ExampleObject;
-               
+
                $args = array( $arg1, $arg2, $arg3, $arg4 );
-               
+
                $newObject = new MWBlankClass( $arg1, $arg2, $arg3, $arg4 );
-               
                $this->assertEquals( 
                        MWFunction::newObj( 'MWBlankClass', $args )->args, 
                        $newObject->args
                );
-               
+
                $this->assertEquals( 
                        MWFunction::newObj( 'MWBlankClass', $args, true )->args, 
                        $newObject->args,
                        'Works even with PHP version < 5.1.3'
                );
-               
        }
        
        /**
         * @expectedException MWException
         */
        function testCallingParentFails() {
-               
                MWFunction::call( 'parent::foo' );
        }
        
@@ -62,7 +54,6 @@ class MWFunctionTest extends MediaWikiTestCase {
         * @expectedException MWException
         */
        function testCallingSelfFails() {
-               
                MWFunction::call( 'self::foo' );
        }
        
@@ -73,13 +64,12 @@ class MWFunctionTest extends MediaWikiTestCase {
 }
 
 class MWBlankClass {
-       
+
        public $args = array();
-       
+
        function __construct( $arg1, $arg2, $arg3, $arg4 ) {
                $this->args = array( $arg1, $arg2, $arg3, $arg4 );
        }
-       
 }
 
 class ExampleObject {
index 3b05d67..5de5cc9 100644 (file)
  *
  */
 class MWNamespaceTest extends MediaWikiTestCase {
-       /**
-        * Sets up the fixture, for example, opens a network connection.
-        * This method is called before a test is executed.
-        */
        protected function setUp() {
-       }
+               parent::setUp();
 
-       /**
-        * Tears down the fixture, for example, closes a network connection.
-        * This method is called after a test is executed.
-        */
-       protected function tearDown() {
+               $this->setMwGlobals( array(
+                       'wgContentNamespaces' => array( NS_MAIN ),
+                       'wgNamespacesWithSubpages' => array(
+                               NS_TALK           => true,
+                               NS_USER           => true,
+                               NS_USER_TALK      => true,
+                       ),
+                       'wgCapitalLinks' => true,
+                       'wgCapitalLinkOverrides' => array(),
+                       'wgNonincludableNamespaces' => array(),
+               ) );
        }
 
-
 #### START OF TESTS #########################################################
 
        /**
@@ -268,77 +269,36 @@ class MWNamespaceTest extends MediaWikiTestCase {
        public function testIsContent() {
                // NS_MAIN is a content namespace per DefaultSettings.php
                // and per function definition.
-               $this->assertIsContent( NS_MAIN );
 
-               global $wgContentNamespaces;
-
-               $saved = $wgContentNamespaces;
-
-               $wgContentNamespaces[] = NS_MAIN;
                $this->assertIsContent( NS_MAIN );
 
                // Other namespaces which are not expected to be content
-               if ( isset( $wgContentNamespaces[NS_MEDIA] ) ) {
-                       unset( $wgContentNamespaces[NS_MEDIA] );
-               }
-               $this->assertIsNotContent( NS_MEDIA );
 
-               if ( isset( $wgContentNamespaces[NS_SPECIAL] ) ) {
-                       unset( $wgContentNamespaces[NS_SPECIAL] );
-               }
+               $this->assertIsNotContent( NS_MEDIA );
                $this->assertIsNotContent( NS_SPECIAL );
-
-               if ( isset( $wgContentNamespaces[NS_TALK] ) ) {
-                       unset( $wgContentNamespaces[NS_TALK] );
-               }
                $this->assertIsNotContent( NS_TALK );
-
-               if ( isset( $wgContentNamespaces[NS_USER] ) ) {
-                       unset( $wgContentNamespaces[NS_USER] );
-               }
                $this->assertIsNotContent( NS_USER );
-
-               if ( isset( $wgContentNamespaces[NS_CATEGORY] ) ) {
-                       unset( $wgContentNamespaces[NS_CATEGORY] );
-               }
                $this->assertIsNotContent( NS_CATEGORY );
-
-               if ( isset( $wgContentNamespaces[100] ) ) {
-                       unset( $wgContentNamespaces[100] );
-               }
                $this->assertIsNotContent( 100 );
-
-               $wgContentNamespaces = $saved;
        }
 
        /**
         * Similar to testIsContent() but alters the $wgContentNamespaces
         * global variable.
         */
-       public function testIsContentWithAdditionsInWgContentNamespaces() {
-               // NS_MAIN is a content namespace per DefaultSettings.php
-               // and per function definition.
-               $this->assertIsContent( NS_MAIN );
+       public function testIsContentAdvanced() {
+               global $wgContentNamespaces;
 
-               // Tests that user defined namespace #252 is not content:
+               // Test that user defined namespace #252 is not content
                $this->assertIsNotContent( 252 );
 
-               # @todo FIXME: Is global saving really required for PHPUnit?
                // Bless namespace # 252 as a content namespace
-               global $wgContentNamespaces;
-               $savedGlobal = $wgContentNamespaces;
                $wgContentNamespaces[] = 252;
+
                $this->assertIsContent( 252 );
 
                // Makes sure NS_MAIN was not impacted
                $this->assertIsContent( NS_MAIN );
-
-               // Restore global
-               $wgContentNamespaces = $savedGlobal;
-
-               // Verify namespaces after global restauration
-               $this->assertIsContent( NS_MAIN  );
-               $this->assertIsNotContent( 252 );
        }
 
        public function testIsWatchable() {
@@ -356,31 +316,21 @@ class MWNamespaceTest extends MediaWikiTestCase {
        }
 
        public function testHasSubpages() {
+               global $wgNamespacesWithSubpages;
+
                // Special namespaces:
                $this->assertHasNotSubpages( NS_MEDIA   );
                $this->assertHasNotSubpages( NS_SPECIAL );
 
-               // namespaces without subpages
-               # save up global
-               global $wgNamespacesWithSubpages;
-               $saved = null;
-               if( array_key_exists( NS_MAIN, $wgNamespacesWithSubpages ) ) {
-                       $saved = $wgNamespacesWithSubpages[NS_MAIN];
-                       unset( $wgNamespacesWithSubpages[NS_MAIN] );
-               }
-
+               // Namespaces without subpages
                $this->assertHasNotSubpages( NS_MAIN );
 
                $wgNamespacesWithSubpages[NS_MAIN] = true;
                $this->assertHasSubpages( NS_MAIN );
+
                $wgNamespacesWithSubpages[NS_MAIN] = false;
                $this->assertHasNotSubpages( NS_MAIN );
 
-               # restore global
-               if( $saved !== null ) {
-                       $wgNamespacesWithSubpages[NS_MAIN] = $saved;
-               }
-
                // Some namespaces with subpages
                $this->assertHasSubpages( NS_TALK      );
                $this->assertHasSubpages( NS_USER      );
@@ -390,22 +340,25 @@ class MWNamespaceTest extends MediaWikiTestCase {
        /**
         */
        public function testGetContentNamespaces() {
+               global $wgContentNamespaces;
+
                $this->assertEquals(
                        array( NS_MAIN ),
                        MWNamespace::getcontentNamespaces(),
                        '$wgContentNamespaces is an array with only NS_MAIN by default'
                );
 
-               global $wgContentNamespaces;
 
-               $saved = $wgContentNamespaces;
                # test !is_array( $wgcontentNamespaces )
                $wgContentNamespaces = '';
                $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
+
                $wgContentNamespaces = false;
                $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
+
                $wgContentNamespaces = null;
                $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
+
                $wgContentNamespaces = 5;
                $this->assertEquals( NS_MAIN, MWNamespace::getcontentNamespaces() );
 
@@ -433,8 +386,6 @@ class MWNamespaceTest extends MediaWikiTestCase {
                        array( NS_MAIN, NS_USER, NS_CATEGORY ),
                        MWNamespace::getcontentNamespaces()
                );
-
-               $wgContentNamespaces = $saved;
        }
 
        /**
@@ -504,24 +455,20 @@ class MWNamespaceTest extends MediaWikiTestCase {
         */
        public function testIsCapitalizedWithWgCapitalLinks() {
                global $wgCapitalLinks;
-               // Save the global to easily reset to MediaWiki default settings
-               $savedGlobal = $wgCapitalLinks;
 
-               $wgCapitalLinks = true;
                $this->assertIsCapitalized( NS_PROJECT      );
                $this->assertIsCapitalized( NS_PROJECT_TALK );
 
                $wgCapitalLinks = false;
+
                // hardcoded namespaces (see above function) are still capitalized:
                $this->assertIsCapitalized( NS_SPECIAL   );
                $this->assertIsCapitalized( NS_USER      );
                $this->assertIsCapitalized( NS_MEDIAWIKI );
+
                // setting is correctly applied
                $this->assertIsNotCapitalized( NS_PROJECT      );
                $this->assertIsNotCapitalized( NS_PROJECT_TALK );
-
-               // reset global state:
-               $wgCapitalLinks = $savedGlobal;
        }
 
        /**
@@ -532,12 +479,11 @@ class MWNamespaceTest extends MediaWikiTestCase {
         */
        public function testIsCapitalizedWithWgCapitalLinkOverrides() {
                global $wgCapitalLinkOverrides;
-               // Save the global to easily reset to MediaWiki default settings
-               $savedGlobal = $wgCapitalLinkOverrides;
 
                // Test default settings
                $this->assertIsCapitalized( NS_PROJECT      );
                $this->assertIsCapitalized( NS_PROJECT_TALK );
+
                // hardcoded namespaces (see above function) are capitalized:
                $this->assertIsCapitalized( NS_SPECIAL   );
                $this->assertIsCapitalized( NS_USER      );
@@ -547,20 +493,19 @@ class MWNamespaceTest extends MediaWikiTestCase {
                $wgCapitalLinkOverrides[NS_SPECIAL]   = false;
                $wgCapitalLinkOverrides[NS_USER]      = false;
                $wgCapitalLinkOverrides[NS_MEDIAWIKI] = false;
+
                $this->assertIsCapitalized( NS_SPECIAL   );
                $this->assertIsCapitalized( NS_USER      );
                $this->assertIsCapitalized( NS_MEDIAWIKI );
 
-               $wgCapitalLinkOverrides = $savedGlobal;
                $wgCapitalLinkOverrides[NS_PROJECT] = false;
                $this->assertIsNotCapitalized( NS_PROJECT );
+
                $wgCapitalLinkOverrides[NS_PROJECT] = true ;
                $this->assertIsCapitalized( NS_PROJECT );
-               unset(  $wgCapitalLinkOverrides[NS_PROJECT] );
-               $this->assertIsCapitalized( NS_PROJECT );
 
-               // reset global state:
-               $wgCapitalLinkOverrides = $savedGlobal;
+               unset( $wgCapitalLinkOverrides[NS_PROJECT] );
+               $this->assertIsCapitalized( NS_PROJECT );
        }
 
        public function testHasGenderDistinction() {
@@ -578,10 +523,10 @@ class MWNamespaceTest extends MediaWikiTestCase {
 
        public function testIsNonincludable() {
                global $wgNonincludableNamespaces;
+
                $wgNonincludableNamespaces = array( NS_USER );
 
                $this->assertTrue( MWNamespace::isNonincludable( NS_USER ) );
-
                $this->assertFalse( MWNamespace::isNonincludable( NS_TEMPLATE ) );
        }
 
index 20181fd..22450dc 100644 (file)
@@ -1,6 +1,14 @@
 <?php
 
 class MessageTest extends MediaWikiLangTestCase {
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( array(
+                       'wgLang' => Language::factory( 'en' ),
+                       'wgForceUIMsgAsContentMsg' => array(),
+               ) );
+       }
 
        function testExists() {
                $this->assertTrue( wfMessage( 'mainpage' )->exists() );
@@ -43,16 +51,11 @@ class MessageTest extends MediaWikiLangTestCase {
 
        function testInContentLanguage() {
                global $wgLang, $wgForceUIMsgAsContentMsg;
-               $oldLang = $wgLang;
                $wgLang = Language::factory( 'fr' );
 
                $this->assertEquals( 'Main Page', wfMessage( 'mainpage' )->inContentLanguage()->plain(), 'ForceUIMsg disabled' );
                $wgForceUIMsgAsContentMsg['testInContentLanguage'] = 'mainpage';
                $this->assertEquals( 'Accueil', wfMessage( 'mainpage' )->inContentLanguage()->plain(), 'ForceUIMsg enabled' );
-
-               /* Restore globals */
-               $wgLang = $oldLang;
-               unset( $wgForceUIMsgAsContentMsg['testInContentLanguage'] );
        }
 
        /**
index 59c955f..5b2adaf 100644 (file)
@@ -5,15 +5,19 @@ class ParserOptionsTest extends MediaWikiTestCase {
        private $popts;
        private $pcache;
 
-       function setUp() {
-               global $wgContLang, $wgUser, $wgLanguageCode;
-               $wgContLang = Language::factory( $wgLanguageCode );
-               $this->popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
-               $this->pcache = ParserCache::singleton();
-       }
+       protected function setUp() {
+               global $wgLanguageCode, $wgUser;
+               parent::setUp();
+
+               $langObj = Language::factory( $wgLanguageCode );
+
+               $this->setMwGlobals( array(
+                       'wgContLang' => $langObj,
+                       'wgUseDynamicDates' => true,
+               ) );
 
-       function tearDown() {
-               parent::tearDown();
+               $this->popts = ParserOptions::newFromUserAndLang( $wgUser, $langObj );
+               $this->pcache = ParserCache::singleton();
        }
 
        /**
@@ -21,14 +25,12 @@ class ParserOptionsTest extends MediaWikiTestCase {
         * @group Database
         */
        function testGetParserCacheKeyWithDynamicDates() {
-               global $wgUseDynamicDates;
-               $wgUseDynamicDates = true;
-
                $title = Title::newFromText( "Some test article" );
                $page = WikiPage::factory( $title );
 
                $pcacheKeyBefore = $this->pcache->getKey( $page, $this->popts );
                $this->assertNotNull( $this->popts->getDateFormat() );
+
                $pcacheKeyAfter = $this->pcache->getKey( $page, $this->popts );
                $this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter );
        }
index f627458..4487210 100644 (file)
@@ -5,7 +5,7 @@
 
 class PathRouterTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
                $router = new PathRouter;
                $router->add("/wiki/$1");
                $this->basicRouter = $router;
@@ -182,7 +182,7 @@ class PathRouterTest extends MediaWikiTestCase {
                $this->assertEquals( $matches, array( 'title' => "Title_With Space" ) );
        }
 
-       public function dataRegexpChars() {
+       public static function provideRegexpChars() {
                return array(
                        array( "$" ),
                        array( "$1" ),
@@ -193,7 +193,7 @@ class PathRouterTest extends MediaWikiTestCase {
 
        /**
         * Make sure the router doesn't break on special characters like $ used in regexp replacements
-        * @dataProvider dataRegexpChars
+        * @dataProvider provideRegexpChars
         */
        public function testRegexpChars( $char ) {
                $matches = $this->basicRouter->parse( "/wiki/$char" );
index 0e12317..1a8a4cc 100644 (file)
@@ -7,7 +7,6 @@ class PreferencesTest extends MediaWikiTestCase {
 
        function __construct() {
                parent::__construct();
-               global $wgEnableEmail;
 
                $this->prefUsers['noemail'] = new User;
 
@@ -23,9 +22,12 @@ class PreferencesTest extends MediaWikiTestCase {
 
                $this->context = new RequestContext;
                $this->context->setTitle( Title::newFromText('PreferencesTest') );
+       }
+
+       protected function setUp() {
+               parent::setUp();
 
-               //some tests depends on email setting
-               $wgEnableEmail = true;
+               $this->setMwGlobals( 'wgEnableEmail', true );
        }
 
        /**
index fbf271c..a1f808c 100644 (file)
@@ -220,7 +220,8 @@ class RecentChangeTest extends MediaWikiTestCase {
         * @todo: Emulate these edits somehow and extract
         * raw edit summary from RecentChange object
         * --
-
+        */
+/*
        function testIrcMsgForBlankingAES() {
                // $this->context->msg( 'autosumm-blank', .. );
        }
@@ -237,8 +238,7 @@ class RecentChangeTest extends MediaWikiTestCase {
                // $this->context->msg( 'undo-summary', .. );
        }
 
-        * --
-        */
+*/
 
        /**
         * @param $expected String Expected IRC text without colors codes
index ab70483..893d260 100644 (file)
@@ -15,7 +15,7 @@ class ResourceLoaderTest extends MediaWikiTestCase {
        }
 
        /* Provider Methods */
-       public function provideValidModules() {
+       public static function provideValidModules() {
                return array(
                        array( 'TEST.validModule1', new ResourceLoaderTestModule() ),
                );
@@ -61,7 +61,7 @@ class ResourceLoaderTest extends MediaWikiTestCase {
                $this->assertEquals( $modules, ResourceLoaderContext::expandModuleNames( $packed ), $desc );
        }
 
-       public function providePackedModules() {
+       public static function providePackedModules() {
                return array(
                        array(
                                'Example from makePackedModulesString doc comment',
index 8a7face..d2ecc55 100644 (file)
@@ -34,7 +34,7 @@ class RevisionStorageTest extends MediaWikiTestCase {
                                                      'iwlinks' ) );
        }
 
-       public function setUp() {
+       protected function setUp() {
                if ( !$this->the_page ) {
                        $this->the_page = $this->createPage( 'RevisionStorageTest_the_page', "just a dummy page" );
                }
@@ -310,7 +310,7 @@ class RevisionStorageTest extends MediaWikiTestCase {
                $this->assertEquals( 'some testing text', $rev->getText() );
        }
 
-       public function dataUserWasLastToEdit() {
+       public static function provideUserWasLastToEdit() {
                return array(
                        array( #0
                                3, true, # actually the last edit
@@ -328,7 +328,7 @@ class RevisionStorageTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataUserWasLastToEdit
+        * @dataProvider provideUserWasLastToEdit
         */
        public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
                $userA = \User::newFromName( "RevisionStorageTest_userA" );
index d7654db..e8f298b 100644 (file)
@@ -1,25 +1,14 @@
 <?php
 
 class RevisionTest extends MediaWikiTestCase {
-       var $saveGlobals = array();
+       protected function setUp() {
+               parent::setUp();
 
-       function setUp() {
-               global $wgContLang;
-               $wgContLang = Language::factory( 'en' );
-               $globalSet = array(
+               $this->setMwGlobals( array(
+                       'wgContLang' => Language::factory( 'en' ),
                        'wgLegacyEncoding' => false,
                        'wgCompressRevisions' => false,
-               );
-               foreach ( $globalSet as $var => $data ) {
-                       $this->saveGlobals[$var] = $GLOBALS[$var];
-                       $GLOBALS[$var] = $data;
-               }
-       }
-
-       function tearDown() {
-               foreach ( $this->saveGlobals as $var => $data ) {
-                       $GLOBALS[$var] = $data;
-               }
+               ) );
        }
 
        function testGetRevisionText() {
@@ -107,7 +96,10 @@ class RevisionTest extends MediaWikiTestCase {
        }
 
        function testCompressRevisionTextUtf8Gzip() {
-               $GLOBALS['wgCompressRevisions'] = true;
+               global $wgCompressRevisions;
+
+               $wgCompressRevisions = true;
+
                $row = new stdClass;
                $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
                $row->old_flags = Revision::compressRevisionText( $row->old_text );
index 59ba0a0..2f55de4 100644 (file)
@@ -5,18 +5,23 @@ class TestSample extends MediaWikiLangTestCase {
        /**
         * Anything that needs to happen before your tests should go here.
         */
-       function setUp() {
-               global $wgContLang;
+       protected function setUp() {
+               // Be sure to do call the parent setup and teardown functions.
+               // This makes sure that all the various cleanup and restorations
+               // happen as they should (including the restoration for setMwGlobals).
                parent::setUp();
 
-               /* For example, we need to set $wgContLang for creating a new Title */
-               $wgContLang = Language::factory( 'en' );
+               // This sets the globals and will restore them automatically
+               // after each test.
+               $this->setMwGlobals( array(
+                       'wgContLang' => Language::factory( 'en' ),
+               ) );
        }
 
        /**
         * Anything cleanup you need to do should go here.
         */
-       function tearDown() {
+       protected function tearDown() {
                parent::tearDown();
        }
 
@@ -40,8 +45,10 @@ class TestSample extends MediaWikiLangTestCase {
        /**
         * If you want to run a the same test with a variety of data. use a data provider.
         * see: http://www.phpunit.de/manual/3.4/en/writing-tests-for-phpunit.html
+        *
+        * Note: Data providers are always called statically and outside setUp/tearDown!
         */
-       public function provideTitles() {
+       public static function provideTitles() {
                return array(
                        array( 'Text', NS_MEDIA, 'Media:Text' ),
                        array( 'Text', null, 'Text' ),
@@ -78,6 +85,7 @@ class TestSample extends MediaWikiLangTestCase {
         * example) as arguments to the next method (e.g. $title in
         * testTitleDepends is whatever testInitialCreatiion returned.)
         */
+
        /**
         * @depends testSetUpMainPageTitleForNextTest
         * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.depends
index ac9971e..c593d2f 100644 (file)
@@ -2,7 +2,11 @@
 
 class SanitizerTest extends MediaWikiTestCase {
 
-       function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( 'wgCleanupPresentationalAttributes', true );
+
                AutoLoader::loadClass( 'Sanitizer' );
        }
 
@@ -110,20 +114,22 @@ class SanitizerTest extends MediaWikiTestCase {
                $this->assertEquals( Sanitizer::decodeTagAttributes( 'foo=&foobar;' ), array( 'foo' => '&foobar;' ), 'Entity-like items are accepted' );
        }
 
-       function testDeprecatedAttributesDisabled() {
-               $GLOBALS['wgCleanupPresentationalAttributes'] = false;
-               $this->assertEquals( ' clear="left"', Sanitizer::fixTagAttributes( 'clear="left"', 'br' ), 'Deprecated attributes are not converted to styles when enabled.' );
-       }
-
        /**
         * @dataProvider provideDeprecatedAttributes
         */
        function testDeprecatedAttributes( $input, $tag, $expected, $message = null ) {
-               $GLOBALS['wgCleanupPresentationalAttributes'] = true;
                $this->assertEquals( $expected, Sanitizer::fixTagAttributes( $input, $tag ), $message );
        }
 
-       function provideDeprecatedAttributes() {
+       function testDeprecatedAttributesDisabled() {
+               global $wgCleanupPresentationalAttributes;
+
+               $wgCleanupPresentationalAttributes = false;
+
+               $this->assertEquals( ' clear="left"', Sanitizer::fixTagAttributes( 'clear="left"', 'br' ), 'Deprecated attributes are not converted to styles when enabled.' );
+       }
+
+       public static function provideDeprecatedAttributes() {
                return array(
                        array( 'clear="left"', 'br', ' style="clear: left;"', 'Deprecated attributes are converted to styles when enabled.' ),
                        array( 'clear="all"', 'br', ' style="clear: both;"', 'clear=all is converted to clear: both; not clear: all;' ),
@@ -170,7 +176,7 @@ class SanitizerTest extends MediaWikiTestCase {
                );
        }
 
-       function provideCssCommentsFixtures() {
+       public static function provideCssCommentsFixtures() {
                /** array( <expected>, <css>, [message] ) */
                return array(
                        array( ' ', '/**/' ),
index 8589c18..8f6aafa 100644 (file)
@@ -99,7 +99,8 @@ testBrowser           = "firefox"
        private $testSuites1 = null;
 
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
                if ( !defined( 'SELENIUMTEST' ) ) {
                        define( 'SELENIUMTEST', true );
                }
@@ -108,7 +109,7 @@ testBrowser                 = "firefox"
        /**
         * Clean up the temporary file used to store the selenium settings.
         */
-       public function tearDown() {
+       protected function tearDown() {
                if ( strlen( $this->tempFileName ) > 0 ) {
                        unlink( $this->tempFileName );
                        unset( $this->tempFileName );
index 57d3532..4e0d2f4 100644 (file)
@@ -25,7 +25,7 @@ function getSiteParams( $conf, $wiki ) {
 class SiteConfigurationTest extends MediaWikiTestCase {
        var $mConf;
 
-       function setUp() {
+       protected function setUp() {
                $this->mConf = new SiteConfiguration;
 
                $this->mConf->suffixes = array( 'wiki' );
index cd027c5..db4162f 100644 (file)
@@ -1,28 +1,21 @@
 <?php
 
 class TimeAdjustTest extends MediaWikiLangTestCase {
-       static $offset;
-
-       public function setUp() {
+       protected function setUp() {
                parent::setUp();
-               global $wgLocalTZoffset;
-               self::$offset = $wgLocalTZoffset;
 
-               $this->iniSet( 'precision', 15 );
-       }
+               $this->setMwGlobals( array(
+                       'wgLocalTZoffset' => null,
+                       'wgContLang' => Language::factory( 'en' ),
+               ) );
 
-       public function tearDown() {
-               global $wgLocalTZoffset;
-               $wgLocalTZoffset = self::$offset;
-               parent::tearDown();
+               $this->iniSet( 'precision', 15 );
        }
 
        # Test offset usage for a given language::userAdjust
        function testUserAdjust() {
                global $wgLocalTZoffset, $wgContLang;
 
-               $wgContLang = $en = Language::factory( 'en' );
-
                #  Collection of parameters for Language_t_Offset.
                # Format: date to be formatted, localTZoffset value, expected date
                $userAdjust_tests = array(
@@ -43,7 +36,7 @@ class TimeAdjustTest extends MediaWikiLangTestCase {
 
                        $this->assertEquals(
                                strval( $data[2] ),
-                               strval( $en->userAdjust( $data[0], '' ) ),
+                               strval( $wgContLang->userAdjust( $data[0], '' ) ),
                                "User adjust {$data[0]} by {$data[1]} minutes should give {$data[2]}"
                        );
                }
index 231228f..53d0424 100644 (file)
@@ -4,6 +4,16 @@
  * Tests timestamp parsing and output.
  */
 class TimestampTest extends MediaWikiTestCase {
+
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( array(
+                       'wgLanguageCode' => 'en',
+                       'wgContLang' => Language::factory( 'en' ),
+                       'wgLang' => Language::factory( 'en' ),
+               ) );
+       }
        /**
         * Test parsing of valid timestamps and outputing to MW format.
         * @dataProvider provideValidTimestamps
@@ -51,7 +61,7 @@ class TimestampTest extends MediaWikiTestCase {
         * Returns a list of valid timestamps in the format:
         * array( type, timestamp_of_type, timestamp_in_MW )
         */
-       function provideValidTimestamps() {
+       public static function provideValidTimestamps() {
                return array(
                        // Various formats
                        array( TS_UNIX, '1343761268', '20120731190108' ),
index aed658b..5a540b8 100644 (file)
@@ -2,7 +2,7 @@
 
 class TitleMethodsTest extends MediaWikiTestCase {
 
-       public function dataEquals() {
+       public static function provideEquals() {
                return array(
                        array( 'Main Page', 'Main Page', true ),
                        array( 'Main Page', 'Not The Main Page', false ),
@@ -15,7 +15,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataEquals
+        * @dataProvider provideEquals
         */
        public function testEquals( $titleA, $titleB, $expectedBool ) {
                $titleA = Title::newFromText( $titleA );
@@ -25,7 +25,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
                $this->assertEquals( $expectedBool, $titleB->equals( $titleA ) );
        }
 
-       public function dataInNamespace() {
+       public static function provideInNamespace() {
                return array(
                        array( 'Main Page', NS_MAIN, true ),
                        array( 'Main Page', NS_TALK, false ),
@@ -39,7 +39,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataInNamespace
+        * @dataProvider provideInNamespace
         */
        public function testInNamespace( $title, $ns, $expectedBool ) {
                $title = Title::newFromText( $title );
@@ -54,7 +54,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
                $this->assertFalse( $mainpage->inNamespaces( array( NS_PROJECT, NS_TEMPLATE ) ) );
        }
 
-       public function dataHasSubjectNamespace() {
+       public static function provideHasSubjectNamespace() {
                return array(
                        array( 'Main Page', NS_MAIN, true ),
                        array( 'Main Page', NS_TALK, true ),
@@ -68,14 +68,14 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataHasSubjectNamespace
+        * @dataProvider provideHasSubjectNamespace
         */
        public function testHasSubjectNamespace( $title, $ns, $expectedBool ) {
                $title = Title::newFromText( $title );
                $this->assertEquals( $expectedBool, $title->hasSubjectNamespace( $ns ) );
        }
 
-       public function dataIsCssOrJsPage() {
+       public static function provideIsCssOrJsPage() {
                return array(
                        array( 'Foo', false ),
                        array( 'Foo.js', false ),
@@ -96,7 +96,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataIsCssOrJsPage
+        * @dataProvider provideIsCssOrJsPage
         */
        public function testIsCssOrJsPage( $title, $expectedBool ) {
                $title = Title::newFromText( $title );
@@ -104,7 +104,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
 
-       public function dataIsCssJsSubpage() {
+       public static function provideIsCssJsSubpage() {
                return array(
                        array( 'Foo', false ),
                        array( 'Foo.js', false ),
@@ -123,14 +123,14 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataIsCssJsSubpage
+        * @dataProvider provideIsCssJsSubpage
         */
        public function testIsCssJsSubpage( $title, $expectedBool ) {
                $title = Title::newFromText( $title );
                $this->assertEquals( $expectedBool, $title->isCssJsSubpage() );
        }
 
-       public function dataIsCssSubpage() {
+       public static function provideIsCssSubpage() {
                return array(
                        array( 'Foo', false ),
                        array( 'Foo.css', false ),
@@ -143,14 +143,14 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataIsCssSubpage
+        * @dataProvider provideIsCssSubpage
         */
        public function testIsCssSubpage( $title, $expectedBool ) {
                $title = Title::newFromText( $title );
                $this->assertEquals( $expectedBool, $title->isCssSubpage() );
        }
 
-       public function dataIsJsSubpage() {
+       public static function provideIsJsSubpage() {
                return array(
                        array( 'Foo', false ),
                        array( 'Foo.css', false ),
@@ -163,14 +163,14 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataIsJsSubpage
+        * @dataProvider provideIsJsSubpage
         */
        public function testIsJsSubpage( $title, $expectedBool ) {
                $title = Title::newFromText( $title );
                $this->assertEquals( $expectedBool, $title->isJsSubpage() );
        }
 
-       public function dataIsWikitextPage() {
+       public static function provideIsWikitextPage() {
                return array(
                        array( 'Foo', true ),
                        array( 'Foo.js', true ),
@@ -191,7 +191,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataIsWikitextPage
+        * @dataProvider provideIsWikitextPage
         */
        public function testIsWikitextPage( $title, $expectedBool ) {
                $title = Title::newFromText( $title );
index f62ac5d..5df8fe1 100644 (file)
@@ -4,31 +4,44 @@
  * @group Database
  */
 class TitlePermissionTest extends MediaWikiLangTestCase {
-       protected $title;
 
        /**
-        * @var User
+        * @var string
         */
-       protected $user, $anonUser, $userUser, $altUser;
+       protected $userName, $altUserName;
 
        /**
-        * @var string
+        * @var Title
         */
-       protected $userName, $altUserName;
+       protected $title;
 
-       function setUp() {
-               global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang;
-               parent::setUp();
+       /**
+        * @var User
+        */
+       protected $user, $anonUser, $userUser, $altUser;
 
-               if(!$wgMemc) {
-                       $wgMemc = new EmptyBagOStuff;
-               }
-               $wgContLang = $wgLang = Language::factory( 'en' );
+       protected function setUp() {
+               parent::setUp();
 
-               $this->userName = "Useruser";
-               $this->altUserName = "Altuseruser";
-               date_default_timezone_set( $wgLocaltimezone );
-               $wgLocalTZoffset = date( "Z" ) / 60;
+               $langObj = Language::factory( 'en' );
+               $localZone = 'UTC';
+               $localOffset = date( 'Z' ) / 60;
+
+               $this->setMwGlobals( array(
+                       'wgMemc' => new EmptyBagOStuff,
+                       'wgContLang' => $langObj,
+                       'wgLang' => $langObj,
+                       'wgLocaltimezone' => $localZone,
+                       'wgLocalTZoffset' => $localOffset,
+                       'wgNamespaceProtection' => array(
+                               NS_MEDIAWIKI => 'editinterface',
+                       ),
+                       'wgUser' => null,
+               ) );
+
+               $this->userName = 'Useruser';
+               $this->altUserName = 'Altuseruser';
+               date_default_timezone_set( $localZone );
 
                $this->title = Title::makeTitle( NS_MAIN, "Main Page" );
                if ( !isset( $this->userUser ) || !( $this->userUser instanceOf User ) ) {
@@ -53,10 +66,7 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
 
                        $this->user = $this->userUser;
                }
-       }
 
-       function tearDown() {
-               parent::tearDown();
        }
 
        function setUserPerm( $perm ) {
@@ -74,6 +84,8 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
        }
 
        function setUser( $userName = null ) {
+               global $wgUser;
+
                if ( $userName === 'anon' ) {
                        $this->user = $this->anonUser;
                } elseif ( $userName === null || $userName === $this->userName ) {
@@ -82,7 +94,6 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                        $this->user = $this->altUser;
                }
 
-               global $wgUser;
                $wgUser = $this->user;
        }
 
@@ -338,9 +349,8 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
        }
 
        function testSpecialsAndNSPermissions() {
+               global $wgNamespaceProtection;
                $this->setUser( $this->userName );
-               global $wgUser;
-               $wgUser = $this->user;
 
                $this->setTitle( NS_SPECIAL );
 
@@ -359,8 +369,8 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                $this->assertEquals( array( array( 'badaccess-group0' ) ),
                                                         $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
 
-               global $wgNamespaceProtection;
-               $wgNamespaceProtection[NS_USER] = array ( 'bogus' );
+               $wgNamespaceProtection[NS_USER] = array( 'bogus' );
+
                $this->setTitle( NS_USER );
                $this->setUserPerm( '' );
                $this->assertEquals( array( array( 'badaccess-group0' ), array( 'namespaceprotected', 'User' ) ),
@@ -377,6 +387,7 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                                                         $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
 
                $wgNamespaceProtection = null;
+
                $this->setUserPerm( 'bogus' );
                $this->assertEquals( array( ),
                                                         $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
@@ -392,8 +403,6 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
 
        function testCssAndJavascriptPermissions() {
                $this->setUser( $this->userName );
-               global $wgUser;
-               $wgUser = $this->user;
 
                $this->setTitle( NS_USER, $this->altUserName . '/test.js' );
                $this->runCSSandJSPermissions(
index c74daae..8c22269 100644 (file)
@@ -2,6 +2,19 @@
 
 class TitleTest extends MediaWikiTestCase {
 
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( array(
+                       'wgLanguageCode' => 'en',
+                       'wgContLang' => Language::factory( 'en' ),
+                       // User language
+                       'wgLang' => Language::factory( 'en' ),
+                       'wgAllowUserJs' => false,
+                       'wgDefaultLanguageVariant' => false,
+               ) );
+       }
+
        function testLegalChars() {
                $titlechars = Title::legalChars();
 
@@ -16,7 +29,7 @@ class TitleTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataBug31100
+        * @dataProvider provideBug31100
         */
        function testBug31100FixSpecialName( $text, $expectedParam ) {
                $title = Title::newFromText( $text );
@@ -30,7 +43,7 @@ class TitleTest extends MediaWikiTestCase {
                $this->assertEquals( $expectedParam, $par, "Bug 31100 regression check: Title->fixSpecialName() should preserve parameter" );
        }
 
-       function dataBug31100() {
+       public static function provideBug31100() {
                return array(
                        array( 'Special:Version', null ),
                        array( 'Special:Version/', '' ),
@@ -45,7 +58,7 @@ class TitleTest extends MediaWikiTestCase {
         * @param string $source
         * @param string $target
         * @param array|string|true $expected Required error
-        * @dataProvider dataTestIsValidMoveOperation
+        * @dataProvider provideTestIsValidMoveOperation
         */
        function testIsValidMoveOperation( $source, $target, $expected ) {
                $title = Title::newFromText( $source );
@@ -69,7 +82,7 @@ class TitleTest extends MediaWikiTestCase {
                return $result;
        }
        
-       function dataTestIsValidMoveOperation() {
+       public static function provideTestIsValidMoveOperation() {
                return array( 
                        array( 'Test', 'Test', 'selfmove' ),
                        array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' )
@@ -79,22 +92,15 @@ class TitleTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideCasesForGetpageviewlanguage
         */
-       function testGetpageviewlanguage( $expected, $titleText, $contLang, $lang, $variant, $msg='' ) {
-               // Save globals
-               global $wgContLang, $wgLang, $wgAllowUserJs, $wgLanguageCode, $wgDefaultLanguageVariant;
-               $save['wgContLang']               = $wgContLang;
-               $save['wgLang']                   = $wgLang;
-               $save['wgAllowUserJs']            = $wgAllowUserJs;
-               $save['wgLanguageCode']           = $wgLanguageCode;
-               $save['wgDefaultLanguageVariant'] = $wgDefaultLanguageVariant;
-
-               // Setup test environnement:
-               $wgContLang = Language::factory( $contLang );
-               $wgLang     = Language::factory( $lang );
-               # To test out .js titles:
-               $wgAllowUserJs = true;
+       function testGetpageviewlanguage( $expected, $titleText, $contLang, $lang, $variant, $msg = '' ) {
+               global $wgLanguageCode, $wgContLang, $wgLang, $wgDefaultLanguageVariant, $wgAllowUserJs;
+
+               // Setup environnement for this test
                $wgLanguageCode = $contLang;
+               $wgContLang = Language::factory( $contLang );
+               $wgLang = Language::factory( $lang );
                $wgDefaultLanguageVariant = $variant;
+               $wgAllowUserJs = true;
 
                $title = Title::newFromText( $titleText );
                $this->assertInstanceOf( 'Title', $title,
@@ -104,13 +110,6 @@ class TitleTest extends MediaWikiTestCase {
                        $title->getPageViewLanguage()->getCode(),
                        $msg
                );
-
-               // Restore globals
-               $wgContLang               = $save['wgContLang'];
-               $wgLang                   = $save['wgLang'];
-               $wgAllowUserJs            = $save['wgAllowUserJs'];
-               $wgLanguageCode           = $save['wgLanguageCode'];
-               $wgDefaultLanguageVariant = $save['wgDefaultLanguageVariant'];
        }
 
        function provideCasesForGetpageviewlanguage() {
@@ -182,7 +181,7 @@ class TitleTest extends MediaWikiTestCase {
                );
        }
 
-       function provideRootTitleCases() {
+       public static function provideRootTitleCases() {
                return array(
                        # Title, expected base, optional message
                        array('User:John_Doe/subOne/subTwo', 'John Doe' ),
index 7a424ae..316e6f5 100644 (file)
@@ -7,22 +7,26 @@ define( 'NS_UNITTEST_TALK', 5601 );
  * @group Database
  */
 class UserTest extends MediaWikiTestCase {
-       protected $savedGroupPermissions, $savedRevokedPermissions;
 
        /**
         * @var User
         */
        protected $user;
 
-       public function setUp() {
+       protected function setUp() {
                parent::setUp();
 
-               $this->savedGroupPermissions = $GLOBALS['wgGroupPermissions'];
-               $this->savedRevokedPermissions = $GLOBALS['wgRevokePermissions'];
+               $this->setMwGlobals( array(
+                       'wgGroupPermissions' => array(),
+                       'wgRevokePermissions' => array(),
+               ) );
 
                $this->setUpPermissionGlobals();
-               $this->setUpUser();
+
+               $this->user = new User;
+               $this->user->addGroup( 'unittesters' );
        }
+
        private function setUpPermissionGlobals() {
                global $wgGroupPermissions, $wgRevokePermissions;
 
@@ -38,22 +42,12 @@ class UserTest extends MediaWikiTestCase {
                        'writetest' => true,
                        'modifytest' => true,
                );
+
                # Data for regular $wgRevokePermissions test
                $wgRevokePermissions['formertesters'] = array(
                        'runtest' => true,
                );
        }
-       private function setUpUser() {
-               $this->user = new User;
-               $this->user->addGroup( 'unittesters' );
-       }
-
-       public function tearDown() {
-               parent::tearDown();
-
-               $GLOBALS['wgGroupPermissions'] = $this->savedGroupPermissions;
-               $GLOBALS['wgRevokePermissions'] = $this->savedRevokedPermissions;
-       }
 
        public function testGroupPermissions() {
                $rights = User::getGroupPermissions( array( 'unittesters' ) );
@@ -95,7 +89,7 @@ class UserTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $result, "Groups with permission $right" );
        }
 
-       public function provideGetGroupsWithPermission() {
+       public static function provideGetGroupsWithPermission() {
                return array(
                        array(
                                array( 'unittesters', 'testwriters' ),
@@ -123,7 +117,7 @@ class UserTest extends MediaWikiTestCase {
                $this->assertEquals( $this->user->isValidUserName( $username ), $result, $message );
        }
 
-       public function provideUserNames() {
+       public static function provideUserNames() {
                return array(
                        array( '', false, 'Empty string' ),
                        array( ' ', false, 'Blank space' ),
index 1fc0b4b..153ff78 100644 (file)
@@ -1,14 +1,18 @@
 <?php
 
 class WebRequestTest extends MediaWikiTestCase {
-       static $oldServer;
+       protected $oldServer;
 
-       function setUp() {
-               self::$oldServer = $_SERVER;
+       protected function setUp() {
+               parent::setUp();
+
+               $this->oldServer = $_SERVER;
        }
 
-       function tearDown() {
-               $_SERVER = self::$oldServer;
+       protected function tearDown() {
+               $_SERVER = $this->oldServer;
+
+               parent::tearDown();
        }
 
        /**
@@ -20,7 +24,7 @@ class WebRequestTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $result, $description );
        }
 
-       function provideDetectServer() {
+       public static function provideDetectServer() {
                return array(
                        array(
                                'http://x',
@@ -107,7 +111,7 @@ class WebRequestTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $result, $description );
        }
 
-       function provideGetIP() {
+       public static function provideGetIP() {
                return array(
                        array(
                                '127.0.0.1',
@@ -189,7 +193,7 @@ class WebRequestTest extends MediaWikiTestCase {
                $request->getIP();
        }
 
-       function languageProvider() {
+       public static function provideLanguageData() {
                return array(
                        array( '', array(), 'Empty Accept-Language header' ),
                        array( 'en', array( 'en' => 1 ), 'One language' ),
@@ -206,7 +210,7 @@ class WebRequestTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider languageProvider
+        * @dataProvider provideLanguageData
         */
        function testAcceptLang($acceptLanguageHeader, $expectedLanguages, $description) {
                $_SERVER = array( 'HTTP_ACCEPT_LANGUAGE' => $acceptLanguageHeader );
index 2949a3a..e77a133 100644 (file)
@@ -29,12 +29,12 @@ class WikiPageTest extends MediaWikiLangTestCase {
                                                       'iwlinks' ) );
        }
 
-       public function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->pages_to_delete = array();
        }
 
-       public function tearDown() {
+       protected function tearDown() {
                foreach ( $this->pages_to_delete as $p ) {
                        /* @var $p WikiPage */
 
@@ -220,7 +220,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $this->assertFalse( $page->exists() );
        }
 
-       public function dataHasViewableContent() {
+       public static function provideHasViewableContent() {
                return array(
                        array( 'WikiPageTest_testHasViewableContent', false, true ),
                        array( 'Special:WikiPageTest_testHasViewableContent', false ),
@@ -231,7 +231,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * @dataProvider dataHasViewableContent
+        * @dataProvider provideHasViewableContent
         */
        public function testHasViewableContent( $title, $viewable, $create = false ) {
                $page = $this->newPage( $title );
@@ -246,7 +246,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                }
        }
 
-       public function dataGetRedirectTarget() {
+       public static function provideGetRedirectTarget() {
                return array(
                        array( 'WikiPageTest_testGetRedirectTarget_1', "hello world", null ),
                        array( 'WikiPageTest_testGetRedirectTarget_2', "#REDIRECT [[hello world]]", "Hello world" ),
@@ -254,7 +254,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * @dataProvider dataGetRedirectTarget
+        * @dataProvider provideGetRedirectTarget
         */
        public function testGetRedirectTarget( $title, $text, $target ) {
                $page = $this->createPage( $title, $text );
@@ -265,14 +265,14 @@ class WikiPageTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * @dataProvider dataGetRedirectTarget
+        * @dataProvider provideGetRedirectTarget
         */
        public function testIsRedirect( $title, $text, $target ) {
                $page = $this->createPage( $title, $text );
                $this->assertEquals( !is_null( $target ), $page->isRedirect() );
        }
 
-       public function dataIsCountable() {
+       public static function provideIsCountable() {
                return array(
 
                        // any
@@ -366,7 +366,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
 
        /**
-        * @dataProvider dataIsCountable
+        * @dataProvider provideIsCountable
         */
        public function testIsCountable( $title, $text, $mode, $expected ) {
                global $wgArticleCountMethod;
@@ -388,7 +388,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                                                    . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
        }
 
-       public function dataGetParserOutput() {
+       public static function provideGetParserOutput() {
                return array(
                        array("hello ''world''\n", "<p>hello <i>world</i></p>"),
                        // @todo: more...?
@@ -396,7 +396,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * @dataProvider dataGetParserOutput
+        * @dataProvider provideGetParserOutput
         */
        public function testGetParserOutput( $text, $expectedHtml ) {
                $page = $this->createPage( 'WikiPageTest_testGetParserOutput', $text );
@@ -427,7 +427,7 @@ more stuff
 ";
 
 
-       public function dataReplaceSection() {
+       public static function provideReplaceSection() {
                return array(
                        array( 'WikiPageTest_testReplaceSection',
                               WikiPageTest::$sections,
@@ -468,7 +468,7 @@ more stuff
        }
 
        /**
-        * @dataProvider dataReplaceSection
+        * @dataProvider provideReplaceSection
         */
        public function testReplaceSection( $title, $text, $section, $with, $sectionTitle, $expected ) {
                $page = $this->createPage( $title, $text );
@@ -613,7 +613,7 @@ more stuff
                $this->assertEquals( "one", $page->getText() );
        }
 
-       public function dataGetAutosummary( ) {
+       public static function provideGetAutosummary( ) {
                return array(
                        array(
                                'Hello there, world!',
@@ -655,7 +655,7 @@ more stuff
        }
 
        /**
-        * @dataProvider dataGetAutoSummary
+        * @dataProvider provideGetAutoSummary
         */
        public function testGetAutosummary( $old, $new, $flags, $expected ) {
                $page = $this->newPage( "WikiPageTest_testGetAutosummary" );
@@ -665,7 +665,7 @@ more stuff
                $this->assertTrue( (bool)preg_match( $expected, $summary ), "Autosummary didn't match expected pattern $expected: $summary" );
        }
 
-       public function dataGetAutoDeleteReason( ) {
+       public static function provideGetAutoDeleteReason( ) {
                return array(
                        array(
                                array(),
@@ -724,7 +724,7 @@ more stuff
        }
 
        /**
-        * @dataProvider dataGetAutoDeleteReason
+        * @dataProvider provideGetAutoDeleteReason
         */
        public function testGetAutoDeleteReason( $edits, $expectedResult, $expectedHistory ) {
                global $wgUser;
@@ -754,7 +754,7 @@ more stuff
                $page->doDeleteArticle( "done" );
        }
 
-       public function dataPreSaveTransform() {
+       public static function providePreSaveTransform() {
                return array(
                        array( 'hello this is ~~~',
                               "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
@@ -766,7 +766,7 @@ more stuff
        }
 
        /**
-        * @dataProvider dataPreSaveTransform
+        * @dataProvider providePreSaveTransform
         */
        public function testPreSaveTransform( $text, $expected ) {
                $this->hideDeprecated( 'WikiPage::preSaveTransform' );
index 2407c15..75bd922 100644 (file)
@@ -35,7 +35,7 @@ class XmlSelectTest extends MediaWikiTestCase {
         * Provides a fourth parameters representing the expected HTML output
         *
         */
-       public function provideConstructionParameters() {
+       public static function provideConstructionParameters() {
                return array(
                        /**
                         * Values are set following a 3-bit Gray code where two successive
index 7f25f58..3cc5422 100644 (file)
@@ -4,17 +4,11 @@ class XmlTest extends MediaWikiTestCase {
        private static $oldLang;
        private static $oldNamespaces;
 
-       public function setUp() {
-               global $wgLang, $wgContLang;
+       protected function setUp() {
+               parent::setUp();
 
-               self::$oldLang = $wgLang;
-               $wgLang = Language::factory( 'en' );
-
-               // Hardcode namespaces during test runs,
-               // so that html output based on existing namespaces
-               // can be properly evaluated.
-               self::$oldNamespaces = $wgContLang->getNamespaces();
-               $wgContLang->setNamespaces( array(
+               $langObj = Language::factory( 'en' );
+               $langObj->setNamespaces( array(
                        -2 => 'Media',
                        -1 => 'Special',
                        0  => '',
@@ -32,13 +26,10 @@ class XmlTest extends MediaWikiTestCase {
                        100  => 'Custom',
                        101  => 'Custom_talk',
                ) );
-       }
 
-       public function tearDown() {
-               global $wgLang, $wgContLang;
-               $wgLang = self::$oldLang;
-
-               $wgContLang->setNamespaces( self::$oldNamespaces );
+               $this->setMwGlobals( array(
+                       'wgLang' => $langObj,
+               ) );
        }
 
        public function testExpandAttributes() {
index d90a695..81b32c2 100644 (file)
@@ -3,7 +3,7 @@
 class ZipDirectoryReaderTest extends MediaWikiTestCase {
        var $zipDir, $entries;
 
-       function setUp() {
+       protected function setUp() {
                $this->zipDir = __DIR__ . '/../data/zip';
        }
 
index 5dfceee..52f1d28 100644 (file)
@@ -6,7 +6,7 @@
  */
 class ApiBlockTest extends ApiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->doLogin();
        }
index 5297d6d..dbf7721 100644 (file)
@@ -10,7 +10,7 @@
  */
 class ApiEditPageTest extends ApiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->doLogin();
        }
index d54d7df..4684c55 100644 (file)
@@ -9,7 +9,7 @@ class ApiOptionsTest extends MediaWikiLangTestCase {
 
        private static $Success = array( 'options' => 'success' );
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
 
                $this->mUserMock = $this->getMockBuilder( 'User' )
index 2566c6c..d903714 100644 (file)
@@ -6,7 +6,7 @@
  */
 class ApiPurgeTest extends ApiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->doLogin();
        }
index a4b9dc7..dbf02f7 100644 (file)
@@ -6,7 +6,7 @@
  */
 class ApiQueryTest extends ApiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->doLogin();
        }
index 3ca6741..de52175 100644 (file)
@@ -8,7 +8,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
         */
        protected $apiContext;
 
-       function setUp() {
+       protected function setUp() {
                global $wgContLang, $wgAuth, $wgMemc, $wgRequest, $wgUser, $wgServer;
 
                parent::setUp();
index 39c7954..9f281bd 100644 (file)
@@ -8,19 +8,23 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
        /**
         * Fixture -- run before every test
         */
-       public function setUp() {
-               global $wgEnableUploads, $wgEnableAPI;
+       protected function setUp() {
                parent::setUp();
 
-               $wgEnableUploads = true;
-               $wgEnableAPI = true;
+               $this->setMwGlobals( array(
+                       'wgEnableUploads' => true,
+                       'wgEnableAPI' => true,
+               ) );
+
                wfSetupSession();
 
                $this->clearFakeUploads();
        }
 
-       public function tearDown() {
+       protected function tearDown() {
                $this->clearTempUpload();
+
+               parent::tearDown();
        }
 
        /**
@@ -54,7 +58,6 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                return $this->deleteFileByTitle( Title::newFromText( $fileName, NS_FILE ) );
        }
 
-
        /**
         * Helper function -- given a file on the filesystem, find matching content in the db (and associated articles) and remove them.
         * @param $filePath String: path to file on the filesystem
@@ -104,6 +107,7 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                return true;
 
        }
+
        function fakeUploadChunk(  $fieldName, $fileName, $type, & $chunkData ){
                $tmpName = tempnam( wfTempDir(), "" );
                // copy the chunk data to temp location: 
@@ -142,7 +146,4 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                $_FILES = array();
        }
 
-
-
-
 }
index d2e9815..cc6c587 100644 (file)
@@ -7,7 +7,7 @@
  */
 class ApiWatchTest extends ApiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->doLogin();
        }
index a8b987e..52cdc78 100644 (file)
@@ -6,7 +6,7 @@
  */
 class GenderCacheTest extends MediaWikiLangTestCase {
 
-       function setUp() {
+       protected function setUp() {
                global $wgDefaultUserOptions;
                parent::setUp();
                //ensure the correct default gender
@@ -45,7 +45,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
        /**
         * test usernames
         *
-        * @dataProvider dataUserName
+        * @dataProvider provideUserGenders
         */
        function testUserName( $username, $expectedGender ) {
                $genderCache = GenderCache::singleton();
@@ -56,7 +56,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
        /**
         * genderCache should work with user objects, too
         *
-        * @dataProvider dataUserName
+        * @dataProvider provideUserGenders
         */
        function testUserObjects( $username, $expectedGender ) {
                $genderCache = GenderCache::singleton();
@@ -65,7 +65,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
                $this->assertEquals( $gender, $expectedGender, "GenderCache normal" );
        }
 
-       function dataUserName() {
+       public static function provideUserGenders() {
                return array(
                        array( 'UTMale', 'male' ),
                        array( 'UTFemale', 'female' ),
@@ -81,7 +81,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
         * test strip of subpages to avoid unnecessary queries
         * against the never existing username
         *
-        * @dataProvider dataStripSubpages
+        * @dataProvider provideStripSubpages
         */
        function testStripSubpages( $pageWithSubpage, $expectedGender ) {
                $genderCache = GenderCache::singleton();
@@ -89,7 +89,7 @@ class GenderCacheTest extends MediaWikiLangTestCase {
                $this->assertEquals( $gender, $expectedGender, "GenderCache must strip of subpages" );
        }
 
-       function dataStripSubpages() {
+       public static function provideStripSubpages() {
                return array(
                        array( 'UTMale/subpage', 'male' ),
                        array( 'UTFemale/subpage', 'female' ),
index 30bfb12..1c081b8 100644 (file)
@@ -76,7 +76,7 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
        /**
         * Value which are forbidden by the constructor
         */
-       function provideInvalidConstructorArg() {
+       public static function provideInvalidConstructorArg() {
                return array(
                        array( null ),
                        array( array() ),
@@ -131,7 +131,7 @@ class ProcessCacheLRUTest extends MediaWikiTestCase {
        /**
         * Provider for testFillingCache
         */
-       function provideCacheFilling() {
+       public static function provideCacheFilling() {
                // ($cacheMaxEntries, $entryToFill, $msg='')
                return array(
                        array( 1,  0 ),
index e37cd44..0c9f749 100644 (file)
@@ -8,15 +8,15 @@
  */
 class DatabaseSQLTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
                // TODO support other DBMS or find another way to do it
-               if( $this->db->getType() !== 'mysql' ) {
+               if ( $this->db->getType() !== 'mysql' ) {
                        $this->markTestSkipped( 'No mysql database' );
                }
        }
 
        /**
-        * @dataProvider dataSelectSQLText
+        * @dataProvider provideSelectSQLText
         */
        function testSelectSQLText( $sql, $sqlText ) {
                $this->assertEquals( trim( $this->db->selectSQLText(
@@ -29,7 +29,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
                ) ), $sqlText );
        }
 
-       function dataSelectSQLText() {
+       public static function provideSelectSQLText() {
                return array(
                        array(
                                array(
@@ -106,7 +106,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataConditional
+        * @dataProvider provideConditional
         */
        function testConditional( $sql, $sqlText ) {
                $this->assertEquals( trim( $this->db->conditional(
@@ -116,7 +116,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
                ) ), $sqlText );
        }
 
-       function dataConditional() {
+       public static function provideConditional() {
                return array(
                        array(
                                array(
index d226598..216de84 100644 (file)
@@ -24,7 +24,9 @@ class MockDatabaseSqlite extends DatabaseSqliteStandalone {
 class DatabaseSqliteTest extends MediaWikiTestCase {
        var $db;
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
                if ( !Sqlite::isPresent() ) {
                        $this->markTestSkipped( 'No SQLite support detected' );
                }
index dc12ba5..a8a6b48 100644 (file)
@@ -7,11 +7,11 @@
 class DatabaseTest extends MediaWikiTestCase {
        var $db, $functionTest = false;
 
-       function setUp() {
+       protected function setUp() {
                $this->db = wfGetDB( DB_MASTER );
        }
 
-       function tearDown() {
+       protected function tearDown() {
                if ( $this->functionTest ) {
                        $this->dropFunctions();
                        $this->functionTest = false;
index afd1cb8..c7bea3b 100644 (file)
@@ -58,7 +58,7 @@ class TestORMRowTest extends ORMRowTest {
                return TestORMTable::singleton();
        }
 
-       public function setUp() {
+       protected function setUp() {
                parent::setUp();
 
                $dbw = wfGetDB( DB_MASTER );
index 246b291..4f338d3 100644 (file)
@@ -3,7 +3,7 @@
 class MWDebugTest extends MediaWikiTestCase {
 
 
-       function setUp() {
+       protected function setUp() {
                // Make sure MWDebug class is enabled
                static $MWDebugEnabled = false;
                if( !$MWDebugEnabled ) {
@@ -15,7 +15,7 @@ class MWDebugTest extends MediaWikiTestCase {
                wfSuppressWarnings();
        }
 
-       function tearDown() {
+       protected function tearDown() {
                wfRestoreWarnings();
        }
 
index cb54bb6..2303c78 100644 (file)
@@ -10,7 +10,7 @@ class FileBackendTest extends MediaWikiTestCase {
        private $filesToPrune = array();
        private static $backendToUse;
 
-       function setUp() {
+       protected function setUp() {
                global $wgFileBackends;
                parent::setUp();
                $tmpPrefix = wfTempDir() . '/filebackend-unittest-' . time() . '-' . mt_rand();
@@ -72,7 +72,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->filesToPrune = array();
        }
 
-       private function baseStorePath() {
+       private static function baseStorePath() {
                return 'mwstore://localtesting';
        }
 
@@ -183,7 +183,7 @@ class FileBackendTest extends MediaWikiTestCase {
                        "FileBackend::extensionFromPath on path '$path'" );
        }
 
-       function provider_testExtensionFromPath() {
+       public static function provider_testExtensionFromPath() {
                return array(
                        array( 'mwstore://backend/container/path.txt', 'txt' ),
                        array( 'mwstore://backend/container/path.svg.png', 'png' ),
@@ -248,11 +248,11 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertBackendPathsConsistent( array( $dest ) );
        }
 
-       public function provider_testStore() {
+       public static function provider_testStore() {
                $cases = array();
 
                $tmpName = TempFSFile::factory( "unittests_", 'txt' )->getPath();
-               $toPath = $this->baseStorePath() . '/unittest-cont1/e/fun/obj1.txt';
+               $toPath = self::baseStorePath() . '/unittest-cont1/e/fun/obj1.txt';
                $op = array( 'op' => 'store', 'src' => $tmpName, 'dst' => $toPath );
                $cases[] = array(
                        $op, // operation
@@ -337,11 +337,11 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertBackendPathsConsistent( array( $source, $dest ) );
        }
 
-       public function provider_testCopy() {
+       public static function provider_testCopy() {
                $cases = array();
 
-               $source = $this->baseStorePath() . '/unittest-cont1/e/file.txt';
-               $dest = $this->baseStorePath() . '/unittest-cont2/a/fileMoved.txt';
+               $source = self::baseStorePath() . '/unittest-cont1/e/file.txt';
+               $dest = self::baseStorePath() . '/unittest-cont2/a/fileMoved.txt';
 
                $op = array( 'op' => 'copy', 'src' => $source, 'dst' => $dest );
                $cases[] = array(
@@ -428,11 +428,11 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertBackendPathsConsistent( array( $source, $dest ) );
        }
 
-       public function provider_testMove() {
+       public static function provider_testMove() {
                $cases = array();
 
-               $source = $this->baseStorePath() . '/unittest-cont1/e/file.txt';
-               $dest = $this->baseStorePath() . '/unittest-cont2/a/fileMoved.txt';
+               $source = self::baseStorePath() . '/unittest-cont1/e/file.txt';
+               $dest = self::baseStorePath() . '/unittest-cont2/a/fileMoved.txt';
 
                $op = array( 'op' => 'move', 'src' => $source, 'dst' => $dest );
                $cases[] = array(
@@ -515,10 +515,10 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertBackendPathsConsistent( array( $source ) );
        }
 
-       public function provider_testDelete() {
+       public static function provider_testDelete() {
                $cases = array();
 
-               $source = $this->baseStorePath() . '/unittest-cont1/e/myfacefile.txt';
+               $source = self::baseStorePath() . '/unittest-cont1/e/myfacefile.txt';
 
                $op = array( 'op' => 'delete', 'src' => $source );
                $cases[] = array(
@@ -611,10 +611,10 @@ class FileBackendTest extends MediaWikiTestCase {
        /**
         * @dataProvider provider_testCreate
         */
-       public function provider_testCreate() {
+       public static function provider_testCreate() {
                $cases = array();
 
-               $dest = $this->baseStorePath() . '/unittest-cont2/a/myspacefile.txt';
+               $dest = self::baseStorePath() . '/unittest-cont2/a/myspacefile.txt';
 
                $op = array( 'op' => 'create', 'content' => 'test test testing', 'dst' => $dest );
                $cases[] = array(
@@ -678,7 +678,7 @@ class FileBackendTest extends MediaWikiTestCase {
        private function doTestDoQuickOperations() {
                $backendName = $this->backendClass();
 
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $files = array(
                        "$base/unittest-cont1/e/fileA.a",
                        "$base/unittest-cont1/e/fileB.a",
@@ -800,16 +800,16 @@ class FileBackendTest extends MediaWikiTestCase {
                $rand = mt_rand( 0, 2000000000 ) . time();
                $dest = wfTempDir() . "/randomfile!$rand.txt";
                $srcs = array(
-                       $this->baseStorePath() . '/unittest-cont1/e/file1.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file2.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file3.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file4.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file5.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file6.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file7.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file8.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file9.txt',
-                       $this->baseStorePath() . '/unittest-cont1/e/file10.txt'
+                       self::baseStorePath() . '/unittest-cont1/e/file1.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file2.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file3.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file4.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file5.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file6.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file7.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file8.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file9.txt',
+                       self::baseStorePath() . '/unittest-cont1/e/file10.txt'
                );
                $content = array(
                        'egfage',
@@ -911,7 +911,7 @@ class FileBackendTest extends MediaWikiTestCase {
        function provider_testGetFileStat() {
                $cases = array();
 
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $cases[] = array( "$base/unittest-cont1/e/b/z/some_file.txt", "some file contents", true );
                $cases[] = array( "$base/unittest-cont1/e/b/some-other_file.txt", "", true );
                $cases[] = array( "$base/unittest-cont1/e/b/some-diff_file.txt", null, false );
@@ -966,7 +966,7 @@ class FileBackendTest extends MediaWikiTestCase {
        function provider_testGetFileContents() {
                $cases = array();
 
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $cases[] = array( "$base/unittest-cont1/e/b/z/some_file.txt", "some file contents" );
                $cases[] = array( "$base/unittest-cont1/e/b/some-other_file.txt", "more file contents" );
                $cases[] = array(
@@ -1031,7 +1031,7 @@ class FileBackendTest extends MediaWikiTestCase {
        function provider_testGetLocalCopy() {
                $cases = array();
 
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $cases[] = array( "$base/unittest-cont1/e/a/z/some_file.txt", "some file contents" );
                $cases[] = array( "$base/unittest-cont1/e/a/some-other_file.txt", "more file contents" );
                $cases[] = array( "$base/unittest-cont1/e/a/\$odd&.txt", "test file contents" );
@@ -1097,7 +1097,7 @@ class FileBackendTest extends MediaWikiTestCase {
        function provider_testGetLocalReference() {
                $cases = array();
 
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $cases[] = array( "$base/unittest-cont1/e/a/z/some_file.txt", "some file contents" );
                $cases[] = array( "$base/unittest-cont1/e/a/some-other_file.txt", "more file contents" );
                $cases[] = array( "$base/unittest-cont1/e/a/\$odd&.txt", "test file contents" );
@@ -1124,7 +1124,7 @@ class FileBackendTest extends MediaWikiTestCase {
        }
 
        function provider_testPrepareAndClean() {
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                return array(
                        array( "$base/unittest-cont1/e/a/z/some_file1.txt", true ),
                        array( "$base/unittest-cont2/a/z/some_file2.txt", true ),
@@ -1172,7 +1172,7 @@ class FileBackendTest extends MediaWikiTestCase {
        private function doTestRecursiveClean() {
                $backendName = $this->backendClass();
 
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $dirs = array(
                        "$base/unittest-cont1/e/a",
                        "$base/unittest-cont1/e/a/b",
@@ -1226,7 +1226,7 @@ class FileBackendTest extends MediaWikiTestCase {
        }
 
        private function doTestDoOperations() {
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
 
                $fileA = "$base/unittest-cont1/e/a/b/fileA.txt";
                $fileAContents = '3tqtmoeatmn4wg4qe-mg3qt3 tq';
@@ -1312,7 +1312,7 @@ class FileBackendTest extends MediaWikiTestCase {
 
        // concurrency orientated
        private function doTestDoOperationsPipeline() {
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
 
                $fileAContents = '3tqtmoeatmn4wg4qe-mg3qt3 tq';
                $fileBContents = 'g-jmq3gpqgt3qtg q3GT ';
@@ -1410,7 +1410,7 @@ class FileBackendTest extends MediaWikiTestCase {
        }
 
        private function doTestDoOperationsFailing() {
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
 
                $fileA = "$base/unittest-cont2/a/b/fileA.txt";
                $fileAContents = '3tqtmoeatmn4wg4qe-mg3qt3 tq';
@@ -1485,7 +1485,7 @@ class FileBackendTest extends MediaWikiTestCase {
 
        private function doTestGetFileList() {
                $backendName = $this->backendClass();
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
 
                // Should have no errors
                $iter = $this->backend->getFileList( array( 'dir' => "$base/unittest-cont-notexists" ) );
@@ -1642,7 +1642,7 @@ class FileBackendTest extends MediaWikiTestCase {
        private function doTestGetDirectoryList() {
                $backendName = $this->backendClass();
 
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $files = array(
                        "$base/unittest-cont1/e/test1.txt",
                        "$base/unittest-cont1/e/test2.txt",
@@ -1901,7 +1901,7 @@ class FileBackendTest extends MediaWikiTestCase {
        }
 
        private function deleteFiles( $container ) {
-               $base = $this->baseStorePath();
+               $base = self::baseStorePath();
                $iter = $this->backend->getFileList( array( 'dir' => "$base/$container" ) );
                if ( $iter ) {
                        foreach ( $iter as $file ) {
@@ -1921,8 +1921,4 @@ class FileBackendTest extends MediaWikiTestCase {
        function assertGoodStatus( $status, $msg ) {
                $this->assertEquals( print_r( array(), 1 ), print_r( $status->errors, 1 ), $msg );
        }
-
-       function tearDown() {
-               parent::tearDown();
-       }
 }
index 3ab56af..7d815e9 100644 (file)
@@ -5,7 +5,7 @@
  */
 class StoreBatchTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
                global $wgFileBackends;
                parent::setUp();
 
@@ -43,6 +43,17 @@ class StoreBatchTest extends MediaWikiTestCase {
                $this->createdFiles = array();
        }
 
+       protected function tearDown() {
+               $this->repo->cleanupBatch( $this->createdFiles ); // delete files
+               foreach ( $this->createdFiles as $tmp ) { // delete dirs
+                       $tmp = $this->repo->resolveVirtualUrl( $tmp );
+                       while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) {
+                               $this->repo->getBackend()->clean( array( 'dir' => $tmp ) );
+                       }
+               }
+               parent::tearDown();
+       }
+
        /**
         * Store a file or virtual URL source into a media file name.
         *
@@ -109,15 +120,4 @@ class StoreBatchTest extends MediaWikiTestCase {
                $this->storecohort( "Test1.png", "$IP/skins/monobook/wiki.png", "$IP/skins/monobook/video.png", false );
                $this->storecohort( "Test2.png", "$IP/skins/monobook/wiki.png", "$IP/skins/monobook/video.png", true );
        }
-
-       public function tearDown() {
-               $this->repo->cleanupBatch( $this->createdFiles ); // delete files
-               foreach ( $this->createdFiles as $tmp ) { // delete dirs
-                       $tmp = $this->repo->resolveVirtualUrl( $tmp );
-                       while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) {
-                               $this->repo->getBackend()->clean( array( 'dir' => $tmp ) );
-                       }
-               }
-               parent::tearDown();
-       }
 }
index a382775..57017a8 100644 (file)
@@ -6,25 +6,16 @@
  */
 
 class CSSMinTest extends MediaWikiTestCase {
-       protected $oldServer = null, $oldCanServer = null;
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
 
-               // Fake $wgServer and $wgCanonicalServer
-               global $wgServer, $wgCanonicalServer;
-               $this->oldServer = $wgServer;
-               $this->oldCanServer = $wgCanonicalServer;
-               $wgServer = $wgCanonicalServer = 'http://wiki.example.org';
-       }
-
-       function tearDown() {
-               // Restore $wgServer and $wgCanonicalServer
-               global $wgServer, $wgCanonicalServer;
-               $wgServer = $this->oldServer;
-               $wgCanonicalServer = $this->oldCanServer;
+               $server = 'http://doc.example.org';
 
-               parent::tearDown();
+               $this->setMwGlobals( array(
+                       'wgServer' => $server,
+                       'wgCanonicalServer' => $server,
+               ) );
        }
 
        /**
@@ -113,7 +104,7 @@ class CSSMinTest extends MediaWikiTestCase {
                        array(
                                'Expand absolute paths',
                                array( 'foo { prop: url(/w/skin/images/bar.png); }', false, 'http://example.org/quux', false ),
-                               'foo { prop: url(http://wiki.example.org/w/skin/images/bar.png); }',
+                               'foo { prop: url(http://doc.example.org/w/skin/images/bar.png); }',
                        ),
                );
        }
index 88f87ef..cfd75d8 100644 (file)
@@ -1,7 +1,11 @@
 <?php
 class BitmapMetadataHandlerTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( 'wgShowEXIF', false );
+
                $this->filePath = __DIR__ . '/../../data/media/';
        }
 
@@ -14,14 +18,15 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
         * translation (to en) where XMP should win.
         */
        public function testMultilingualCascade() {
+               global $wgShowEXIF;
+
                if ( !wfDl( 'exif' ) ) {
                        $this->markTestSkipped( "This test needs the exif extension." );
                }
                if ( !wfDl( 'xml' ) ) {
                        $this->markTestSkipped( "This test needs the xml extension." );
                }
-               global $wgShowEXIF;
-               $oldExif = $wgShowEXIF;
+
                $wgShowEXIF = true;
 
                $meta = BitmapMetadataHandler::Jpeg( $this->filePath .
@@ -37,8 +42,6 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
                        'Did not extract any ImageDescription info?!' );
 
                $this->assertEquals( $expected, $meta['ImageDescription'] );
-
-               $wgShowEXIF = $oldExif;
        }
 
        /**
@@ -73,6 +76,7 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
                $this->assertEquals( '2020:07:14 01:36:05', $meta['DateTimeDigitized'] );
                $this->assertEquals( '1997:03:02 00:01:02', $meta['DateTimeOriginal'] );
        }
+
        /**
         * File has an invalid time (+ one valid but really weird time)
         * that shouldn't be included
@@ -131,12 +135,14 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
                );
                $this->assertEquals( $expected, $result ); 
        }
+
        public function testPNGNative() {
                $handler = new BitmapMetadataHandler();
                $result = $handler->png( $this->filePath . 'Png-native-test.png' );
                $expected = 'http://example.com/url';
                $this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] ); 
        }
+
        public function testTiffByteOrder() {
                $handler = new BitmapMetadataHandler();
                $res = $handler->getTiffByteOrder( $this->filePath . 'test.tiff' );
index 11d9dc4..eb1a536 100644 (file)
@@ -2,18 +2,15 @@
 
 class BitmapScalingTest extends MediaWikiTestCase {
 
-       function setUp() {
-               global $wgMaxImageArea, $wgCustomConvertCommand;
-               $this->oldMaxImageArea = $wgMaxImageArea;
-               $this->oldCustomConvertCommand = $wgCustomConvertCommand;
-               $wgMaxImageArea = 1.25e7; // 3500x3500 
-               $wgCustomConvertCommand = 'dummy'; // Set so that we don't get client side rendering
-       }
-       function tearDown() {
-               global $wgMaxImageArea, $wgCustomConvertCommand;
-               $wgMaxImageArea = $this->oldMaxImageArea;
-               $wgCustomConvertCommand = $this->oldCustomConvertCommand;
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( array(
+                       'wgMaxImageArea' => 1.25e7, // 3500x3500
+                       'wgCustomConvertCommand' => 'dummy', // Set so that we don't get client side rendering
+               ) );
        }
+
        /**
         * @dataProvider provideNormaliseParams
         */
@@ -103,7 +100,8 @@ class BitmapScalingTest extends MediaWikiTestCase {
                                'Bigger than max image size but doesn\'t need scaling',
                        ),
                );
-       } 
+       }
+
        function testTooBigImage() {
                $file = new FakeDimensionFile( array( 4000, 4000 ) );
                $handler = new BitmapHandler;
@@ -111,6 +109,7 @@ class BitmapScalingTest extends MediaWikiTestCase {
                $this->assertEquals( 'TransformParameterError', 
                        get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
        }
+
        function testTooBigMustRenderImage() {
                $file = new FakeDimensionFile( array( 4000, 4000 ) );
                $file->mustRender = true;
index b2f6b7b..dd22321 100644 (file)
@@ -2,43 +2,44 @@
 
 class ExifBitmapTest extends MediaWikiTestCase {
 
-       public function setUp() {
-               global $wgShowEXIF;
-               $this->showExif = $wgShowEXIF;
-               $wgShowEXIF = true;
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( 'wgShowEXIF', true );
+
                $this->handler = new ExifBitmapHandler;
                if ( !wfDl( 'exif' ) ) {
                        $this->markTestSkipped( "This test needs the exif extension." );
                }
        }
 
-       public function tearDown() {
-               global $wgShowEXIF;
-               $wgShowEXIF = $this->showExif;
-       }
-
        public function testIsOldBroken() {
                $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::OLD_BROKEN_FILE );
                $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res );
        }
+
        public function testIsBrokenFile() {
                $res = $this->handler->isMetadataValid( null, ExifBitmapHandler::BROKEN_FILE );
                $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
        }
+
        public function testIsInvalid() {
                $res = $this->handler->isMetadataValid( null, 'Something Invalid Here.' );
                $this->assertEquals( ExifBitmapHandler::METADATA_BAD, $res );
        }
+
        public function testGoodMetadata() {
                $meta = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_GOOD, $res );
        }
+
        public function testIsOldGood() {
                $meta = 'a:16:{s:10:"ImageWidth";i:20;s:11:"ImageLength";i:20;s:13:"BitsPerSample";a:3:{i:0;i:8;i:1;i:8;i:2;i:8;}s:11:"Compression";i:5;s:25:"PhotometricInterpretation";i:2;s:16:"ImageDescription";s:17:"Created with GIMP";s:12:"StripOffsets";i:8;s:11:"Orientation";i:1;s:15:"SamplesPerPixel";i:3;s:12:"RowsPerStrip";i:64;s:15:"StripByteCounts";i:238;s:11:"XResolution";s:19:"1207959552/16777216";s:11:"YResolution";s:19:"1207959552/16777216";s:19:"PlanarConfiguration";i:1;s:14:"ResolutionUnit";i:2;s:22:"MEDIAWIKI_EXIF_VERSION";i:1;}';
                $res = $this->handler->isMetadataValid( null, $meta );
                $this->assertEquals( ExifBitmapHandler::METADATA_COMPATIBLE, $res );
        }
+
        // Handle metadata from paged tiff handler (gotten via instant commons)
        // gracefully.
        public function testPagedTiffHandledGracefully() {
@@ -55,6 +56,7 @@ class ExifBitmapTest extends MediaWikiTestCase {
                $res = $this->handler->convertMetadataVersion( $metadata, 2 );
                $this->assertEquals( $metadata, $res );
        }
+
        function testConvertMetadataToOld() {
                $metadata = array(
                        'foo' => array( 'First', 'Second', '_type' => 'ol' ),
@@ -73,6 +75,7 @@ class ExifBitmapTest extends MediaWikiTestCase {
                $res = $this->handler->convertMetadataVersion( $metadata, 1 );
                $this->assertEquals( $expected, $res );
        }
+
        function testConvertMetadataSoftware() {
                $metadata = array(
                        'Software' => array( array('GIMP', '1.1' ) ),
@@ -85,6 +88,7 @@ class ExifBitmapTest extends MediaWikiTestCase {
                $res = $this->handler->convertMetadataVersion( $metadata, 1 );
                $this->assertEquals( $expected, $res );
        }
+
        function testConvertMetadataSoftwareNormal() {
                $metadata = array(
                        'Software' => array( "GIMP 1.2", "vim" ),
index 6af52dd..692a5f9 100644 (file)
@@ -5,7 +5,7 @@
  */
 class ExifRotationTest extends MediaWikiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->handler = new BitmapHandler();
                $filePath = __DIR__ . '/../../data/media';
@@ -33,7 +33,7 @@ class ExifRotationTest extends MediaWikiTestCase {
                $wgEnableAutoRotation = true;
        }
 
-       public function tearDown() {
+       protected function tearDown() {
                global $wgShowEXIF, $wgEnableAutoRotation;
                $wgShowEXIF = $this->show;
                $wgEnableAutoRotation = $this->oldAuto;
@@ -43,7 +43,7 @@ class ExifRotationTest extends MediaWikiTestCase {
 
        /**
         *
-        * @dataProvider providerFiles
+        * @dataProvider provideFiles
         */
        function testMetadata( $name, $type, $info ) {
                if ( !BitmapHandler::canRotate() ) {
@@ -56,7 +56,7 @@ class ExifRotationTest extends MediaWikiTestCase {
 
        /**
         *
-        * @dataProvider providerFiles
+        * @dataProvider provideFiles
         */
        function testRotationRendering( $name, $type, $info, $thumbs ) {
                if ( !BitmapHandler::canRotate() ) {
@@ -94,12 +94,13 @@ class ExifRotationTest extends MediaWikiTestCase {
                }
        }
 
+       /* Utility function */
        private function dataFile( $name, $type ) {
                return new UnregisteredLocalFile( false, $this->repo,
                        "mwstore://localtesting/data/$name", $type );
        }
 
-       function providerFiles() {
+       public static function provideFiles() {
                return array(
                        array(
                                'landscape-plain.jpg',
@@ -134,7 +135,7 @@ class ExifRotationTest extends MediaWikiTestCase {
 
        /**
         * Same as before, but with auto-rotation disabled.
-        * @dataProvider providerFilesNoAutoRotate
+        * @dataProvider provideFilesNoAutoRotate
         */
        function testMetadataNoAutoRotate( $name, $type, $info ) {
                global $wgEnableAutoRotation;
@@ -149,7 +150,7 @@ class ExifRotationTest extends MediaWikiTestCase {
 
        /**
         *
-        * @dataProvider providerFilesNoAutoRotate
+        * @dataProvider provideFilesNoAutoRotate
         */
        function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) {
                global $wgEnableAutoRotation;
@@ -188,7 +189,7 @@ class ExifRotationTest extends MediaWikiTestCase {
                $wgEnableAutoRotation = true;
        }
 
-       function providerFilesNoAutoRotate() {
+       public static function provideFilesNoAutoRotate() {
                return array(
                        array(
                                'landscape-plain.jpg',
index 045777d..7cc56f6 100644 (file)
@@ -1,20 +1,16 @@
 <?php
 class ExifTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
                $this->mediaPath = __DIR__ . '/../../data/media/';
 
                if ( !wfDl( 'exif' ) ) {
                        $this->markTestSkipped( "This test needs the exif extension." );
                }
-               global $wgShowEXIF;
-               $this->showExif = $wgShowEXIF;
-               $wgShowEXIF = true;
-       }
 
-       public function tearDown() {
-               global $wgShowEXIF;
-               $wgShowEXIF = $this->showExif;
+               $this->setMwGlobals( 'wgShowEXIF', true );
        }
 
        public function testGPSExtraction() {
index 6ade670..4dadde5 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 class FormatMetadataTest extends MediaWikiTestCase {
-       public function setUp() {
+
+       protected function setUp() {
+               parent::setUp();
+
                if ( !wfDl( 'exif' ) ) {
                        $this->markTestSkipped( "This test needs the exif extension." );
                }
@@ -15,13 +18,8 @@ class FormatMetadataTest extends MediaWikiTestCase {
                        'url'     => 'http://localhost/thumbtest',
                        'backend' => $this->backend
                ) );
-               global $wgShowEXIF;
-               $this->show = $wgShowEXIF;
-               $wgShowEXIF = true;
-       }
-       public function tearDown() {
-               global $wgShowEXIF;
-               $wgShowEXIF = $this->show;
+
+               $this->setMwGlobals( 'wgShowEXIF', true );
        }
 
        public function testInvalidDate() {
index 650fdd5..3a750aa 100644 (file)
@@ -1,20 +1,22 @@
 <?php
 class GIFMetadataExtractorTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
                $this->mediaPath = __DIR__ . '/../../data/media/';
        }
        /**
         * Put in a file, and see if the metadata coming out is as expected.
         * @param $filename String
         * @param $expected Array The extracted metadata.
-        * @dataProvider dataGetMetadata
+        * @dataProvider provideGetMetadata
         */
        public function testGetMetadata( $filename, $expected ) {
                $actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
                $this->assertEquals( $expected, $actual );
        }
-       public function dataGetMetadata() {
+       public static function provideGetMetadata() {
 
                $xmpNugget = <<<EOF
 <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
index 5dcbeee..9ffc764 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 class GIFHandlerTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
                $this->filePath = __DIR__ .  '/../../data/media';
                $this->backend = new FSFileBackend( array(
                        'name'           => 'localtesting',
@@ -20,17 +22,18 @@ class GIFHandlerTest extends MediaWikiTestCase {
                $res = $this->handler->getMetadata( null, $this->filePath . '/README' );
                $this->assertEquals( GIFHandler::BROKEN_FILE, $res );
        }
+
        /**
         * @param $filename String basename of the file to check
         * @param $expected boolean Expected result.
-        * @dataProvider dataIsAnimated
+        * @dataProvider provideIsAnimated
         */
        public function testIsAnimanted( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/gif' );
                $actual = $this->handler->isAnimatedImage( $file );
                $this->assertEquals( $expected, $actual );
        }
-       public function dataIsAnimated() {
+       public static function provideIsAnimated() {
                return array(
                        array( 'animated.gif', true ),
                        array( 'nonanimated.gif', false ),
@@ -40,14 +43,14 @@ class GIFHandlerTest extends MediaWikiTestCase {
        /**
         * @param $filename String
         * @param $expected Integer Total image area
-        * @dataProvider dataGetImageArea
+        * @dataProvider provideGetImageArea
         */
        public function testGetImageArea( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/gif' );
                $actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() );
                $this->assertEquals( $expected, $actual );
        }
-       public function dataGetImageArea() {
+       public static function provideGetImageArea() {
                return array(
                        array( 'animated.gif', 5400 ),
                        array( 'nonanimated.gif', 1350 ),
@@ -57,13 +60,13 @@ class GIFHandlerTest extends MediaWikiTestCase {
        /**
         * @param $metadata String Serialized metadata
         * @param $expected Integer One of the class constants of GIFHandler
-        * @dataProvider dataIsMetadataValid
+        * @dataProvider provideIsMetadataValid
         */
        public function testIsMetadataValid( $metadata, $expected ) {
                $actual = $this->handler->isMetadataValid( null, $metadata );
                $this->assertEquals( $expected, $actual );
        }
-       public function dataIsMetadataValid() {
+       public static function provideIsMetadataValid() {
                return array(
                        array( GIFHandler::BROKEN_FILE, GIFHandler::METADATA_GOOD ),
                        array( '', GIFHandler::METADATA_BAD ),
@@ -76,7 +79,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
        /**
         * @param $filename String
         * @param $expected String Serialized array
-        * @dataProvider dataGetMetadata
+        * @dataProvider provideGetMetadata
         */
        public function testGetMetadata( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/gif' );
@@ -84,7 +87,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
                $this->assertEquals( unserialize( $expected ), unserialize( $actual ) );
        }
 
-       public function dataGetMetadata() {
+       public static function provideGetMetadata() {
                return array(
                        array( 'nonanimated.gif', 'a:4:{s:10:"frameCount";i:1;s:6:"looped";b:0;s:8:"duration";d:0.1000000000000000055511151231257827021181583404541015625;s:8:"metadata";a:2:{s:14:"GIFFileComment";a:1:{i:0;s:35:"GIF test file ⁕ Created with GIMP";}s:15:"_MW_GIF_VERSION";i:1;}}' ),
                        array( 'animated-xmp.gif', 'a:4:{s:10:"frameCount";i:4;s:6:"looped";b:1;s:8:"duration";d:2.399999999999999911182158029987476766109466552734375;s:8:"metadata";a:5:{s:6:"Artist";s:7:"Bawolff";s:16:"ImageDescription";a:2:{s:9:"x-default";s:18:"A file to test GIF";s:5:"_type";s:4:"lang";}s:15:"SublocationDest";s:13:"The interwebs";s:14:"GIFFileComment";a:1:{i:0;s:16:"GIƒ·test·file";}s:15:"_MW_GIF_VERSION";i:1;}}' ),
index 41d8119..6e1c0af 100644 (file)
@@ -8,7 +8,9 @@
  */
 class JpegMetadataExtractorTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
                $this->filePath = __DIR__ . '/../../data/media/';
        }
 
@@ -18,13 +20,13 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase {
         *
         * @param $file filename
         *
-        * @dataProvider dataUtf8Comment
+        * @dataProvider provideUtf8Comment
         */
        public function testUtf8Comment( $file ) {
                $res = JpegMetadataExtractor::segmentSplitter( $this->filePath . $file );
                $this->assertEquals( array( 'UTF-8 JPEG Comment — ¼' ), $res['COM'] );
        }
-       public function dataUtf8Comment() {
+       public static function provideUtf8Comment() {
                return array(
                        array( 'jpeg-comment-utf.jpg' ),
                        array( 'jpeg-padding-even.jpg' ),
index ea007f9..05d3661 100644 (file)
@@ -1,18 +1,15 @@
 <?php
 class JpegTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
                $this->filePath = __DIR__ . '/../../data/media/';
                if ( !wfDl( 'exif' ) ) {
                        $this->markTestSkipped( "This test needs the exif extension." );
                }
-               global $wgShowEXIF;
-               $this->show = $wgShowEXIF;
-               $wgShowEXIF = true;
-       }
-       public function tearDown() {
-               global $wgShowEXIF;
-               $wgShowEXIF = $this->show;
+
+               $this->setMwGlobals( 'wgShowEXIF', true );
        }
 
        public function testInvalidFile() {
@@ -20,6 +17,7 @@ class JpegTest extends MediaWikiTestCase {
                $res = $jpeg->getMetadata( null, $this->filePath . 'README' );
                $this->assertEquals( ExifBitmapHandler::BROKEN_FILE, $res );
        }
+
        public function testJpegMetadataExtraction() {
                $h = new JpegHandler;
                $res = $h->getMetadata( null, $this->filePath . 'test.jpg' );
index 1b1b2ec..ee1c6f8 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 class PNGMetadataExtractorTest extends MediaWikiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                $this->filePath = __DIR__ . '/../../data/media/';
        }
        /**
@@ -60,6 +60,8 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
        /**
         * Test extraction of pHYs tags, which can tell what the
         * actual resolution of the image is (aka in dots per meter).
+        */
+/*
        function testPngPhysTag () {
                $meta = PNGMetadataExtractor::getMetadata( $this->filePath .
                        'Png-native-test.png' );
@@ -71,6 +73,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
                $this->assertEquals( '2835/100', $meta['YResolution'] );
                $this->assertEquals( 3, $meta['ResolutionUnit'] ); // 3 = cm
        }
+*/
 
        /**
         * Given a normal static PNG, check the animation metadata returned.
index fe73c9c..2075758 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 class PNGHandlerTest extends MediaWikiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
+               parent::setUp();
+
                $this->filePath = __DIR__ .  '/../../data/media';
                $this->backend = new FSFileBackend( array(
                        'name'           => 'localtesting',
@@ -23,14 +25,14 @@ class PNGHandlerTest extends MediaWikiTestCase {
        /**
         * @param $filename String basename of the file to check
         * @param $expected boolean Expected result.
-        * @dataProvider dataIsAnimated
+        * @dataProvider provideIsAnimated
         */
        public function testIsAnimanted( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/png' );
                $actual = $this->handler->isAnimatedImage( $file );
                $this->assertEquals( $expected, $actual );
        }
-       public function dataIsAnimated() {
+       public static function provideIsAnimated() {
                return array(
                        array( 'Animated_PNG_example_bouncing_beach_ball.png', true ),
                        array( '1bit-png.png', false ),
@@ -40,14 +42,14 @@ class PNGHandlerTest extends MediaWikiTestCase {
        /**
         * @param $filename String
         * @param $expected Integer Total image area
-        * @dataProvider dataGetImageArea
+        * @dataProvider provideGetImageArea
         */
        public function testGetImageArea( $filename, $expected ) {
                $file = $this->dataFile($filename, 'image/png' );
                $actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() );
                $this->assertEquals( $expected, $actual );
        }
-       public function dataGetImageArea() {
+       public static function provideGetImageArea() {
                return array(
                        array( '1bit-png.png', 2500 ),
                        array( 'greyscale-png.png', 2500 ),
@@ -59,13 +61,13 @@ class PNGHandlerTest extends MediaWikiTestCase {
        /**
         * @param $metadata String Serialized metadata
         * @param $expected Integer One of the class constants of PNGHandler
-        * @dataProvider dataIsMetadataValid
+        * @dataProvider provideIsMetadataValid
         */
        public function testIsMetadataValid( $metadata, $expected ) {
                $actual = $this->handler->isMetadataValid( null, $metadata );
                $this->assertEquals( $expected, $actual );
        }
-       public function dataIsMetadataValid() {
+       public static function provideIsMetadataValid() {
                return array(
                        array( PNGHandler::BROKEN_FILE, PNGHandler::METADATA_GOOD ),
                        array( '', PNGHandler::METADATA_BAD ),
@@ -78,7 +80,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
        /**
         * @param $filename String
         * @param $expected String Serialized array
-        * @dataProvider dataGetMetadata
+        * @dataProvider provideGetMetadata
         */
        public function testGetMetadata( $filename, $expected ) {
                $file = $this->dataFile( $filename, 'image/png' );
@@ -86,7 +88,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
 //             $this->assertEquals( unserialize( $expected ), unserialize( $actual ) );
                $this->assertEquals( ( $expected ), ( $actual ) );
        }
-       public function dataGetMetadata() {
+       public static function provideGetMetadata() {
                return array(
                        array( 'rgb-na-png.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:8;s:9:"colorType";s:10:"truecolour";s:8:"metadata";a:1:{s:15:"_MW_PNG_VERSION";i:1;}}' ),
                        array( 'xmp.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:1;s:9:"colorType";s:14:"index-coloured";s:8:"metadata";a:2:{s:12:"SerialNumber";s:9:"123456789";s:15:"_MW_PNG_VERSION";i:1;}}' ), 
index 2116554..007ce46 100644 (file)
@@ -2,19 +2,19 @@
 
 class SVGMetadataExtractorTest extends MediaWikiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                AutoLoader::loadClass( 'SVGMetadataExtractorTest' );
        }
 
        /**
-        * @dataProvider providerSvgFiles
+        * @dataProvider provideSvgFiles
         */
        function testGetMetadata( $infile, $expected ) {
                $this->assertMetadata( $infile, $expected );
        }
        
        /**
-        * @dataProvider providerSvgFilesWithXMLMetadata
+        * @dataProvider provideSvgFilesWithXMLMetadata
         */
        function testGetXMLMetadata( $infile, $expected ) {
                $r = new XMLReader();
@@ -38,7 +38,7 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
                }
        }
 
-       function providerSvgFiles() {
+       public static function provideSvgFiles() {
                $base = __DIR__ . '/../../data/media';
                return array(
                        array(
@@ -81,7 +81,7 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
                );
        }
 
-       function providerSvgFilesWithXMLMetadata() {
+       public static function provideSvgFilesWithXMLMetadata() {
                $base = __DIR__ . '/../../data/media';
                $metadata = 
     '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
index 4c79f66..91c35c4 100644 (file)
@@ -1,19 +1,15 @@
 <?php
 class TiffTest extends MediaWikiTestCase {
 
-       public function setUp() {
-               global $wgShowEXIF;
-               $this->showExif = $wgShowEXIF;
-               $wgShowEXIF = true;
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( 'wgShowEXIF', true );
+
                $this->filePath = __DIR__ . '/../../data/media/';
                $this->handler = new TiffHandler;
        }
 
-       public function tearDown() {
-               global $wgShowEXIF;
-               $wgShowEXIF = $this->showExif;
-       }
-
        public function testInvalidFile() {
                if ( !wfDl( 'exif' ) ) {
                        $this->markTestIncomplete( "This test needs the exif extension." );
index 8198d3b..be02dd7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 class XMPTest extends MediaWikiTestCase {
 
-       function setUp() {
+       protected function setUp() {
                if ( !wfDl( 'xml' ) ) {
                        $this->markTestSkipped( 'Requires libxml to do XMP parsing' );
                }
@@ -14,7 +14,7 @@ class XMPTest extends MediaWikiTestCase {
         * @param $expected Array expected result of parsing the xmp.
         * @param $info String Short sentence on what's being tested.
         *
-        * @dataProvider dataXMPParse
+        * @dataProvider provideXMPParse
         */
        public function testXMPParse( $xmp, $expected, $info ) {
                if ( !is_string( $xmp ) || !is_array( $expected ) ) {
@@ -25,7 +25,7 @@ class XMPTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $reader->getResults(), $info, 0.0000000001 );
        }
 
-       public function dataXMPParse() {
+       public static function provideXMPParse() {
                $xmpPath = __DIR__ . '/../../data/xmp/' ;
                $data = array();
 
index e2bb8d8..a2b4e1c 100644 (file)
@@ -2,7 +2,7 @@
 class XMPValidateTest extends MediaWikiTestCase {
 
        /**
-        * @dataProvider providerDate
+        * @dataProvider provideDates
         */
        function testValidateDate( $value, $expected ) {
                // The method should modify $value.
@@ -10,7 +10,7 @@ class XMPValidateTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $value );
        }
 
-       function providerDate() {
+       public static function provideDates() {
                /* For reference valid date formats are:
                 * YYYY
                 * YYYY-MM
index 0e15653..2588691 100644 (file)
@@ -13,7 +13,7 @@
                $this->assertEquals( $format, $detector->detectFormatName( $userAgent ) );
        }
 
-       public function provideTestFormatName() {
+       public static function provideTestFormatName() {
                return array(
                        array( 'android',   'Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17' ),
                        array( 'iphone2',   'Mozilla/5.0 (ipod: U;CPU iPhone OS 2_2 like Mac OS X: es_es) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3' ),
index 3164531..46ef5da 100644 (file)
@@ -29,9 +29,10 @@ class MagicVariableTest extends MediaWikiTestCase {
        );
 
        /** setup a basic parser object */
-       function setUp() {
-               global $wgContLang;
-               $wgContLang = Language::factory( 'en' );
+       protected function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( 'wgContLang', Language::factory( 'en' ) );
 
                $this->testParser = new Parser();
                $this->testParser->Options( new ParserOptions() );
@@ -47,8 +48,10 @@ class MagicVariableTest extends MediaWikiTestCase {
        }
 
        /** destroy parser (TODO: is it really neded?)*/
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->testParser );
+
+               parent::tearDown();
        }
 
        ############### TESTS #############################################
index ff6e472..848991e 100644 (file)
@@ -9,7 +9,7 @@
  */
 class NewParserTest extends MediaWikiTestCase {
        static protected $articles = array();   // Array of test articles defined by the tests
-       /* The dataProvider is run on a different instance than the test, so it must be static
+       /* The data provider is run on a different instance than the test, so it must be static
         * When running tests from several files, all tests will see all articles.
         */
        static protected $backendToUse;
@@ -31,7 +31,7 @@ class NewParserTest extends MediaWikiTestCase {
 
        protected $file = false;
 
-       function setUp() {
+       protected function setUp() {
                global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases;
                global $wgHooks, $IP;
                $wgContLang = Language::factory( 'en' );
@@ -100,7 +100,7 @@ class NewParserTest extends MediaWikiTestCase {
                $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
        }
 
-       public function tearDown() {
+       protected function tearDown() {
                foreach ( $this->savedInitialGlobals as $var => $val ) {
                        $GLOBALS[$var] = $val;
                }
index dea406c..e0f95b6 100644 (file)
@@ -2,7 +2,7 @@
 
 class ParserMethodsTest extends MediaWikiLangTestCase {
 
-       public function dataPreSaveTransform() {
+       public static function providePreSaveTransform() {
                return array(
                        array( 'hello this is ~~~',
                               "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
@@ -14,7 +14,7 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * @dataProvider dataPreSaveTransform
+        * @dataProvider providePreSaveTransform
         */
        public function testPreSaveTransform( $text, $expected ) {
                global $wgParser;
index 0e8ef53..d537b6e 100644 (file)
@@ -8,7 +8,7 @@ class ParserPreloadTest extends MediaWikiTestCase {
        private $testParserOptions;
        private $title;
 
-       function setUp() {
+       protected function setUp() {
                $this->testParserOptions = new ParserOptions();
 
                $this->testParser = new Parser();
@@ -18,7 +18,7 @@ class ParserPreloadTest extends MediaWikiTestCase {
                $this->title = Title::newFromText( 'Preload Test' );
        }
 
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->testParser );
                unset( $this->title );
        }
index fee5674..d82fc6c 100644 (file)
@@ -5,7 +5,7 @@ class PreprocessorTest extends MediaWikiTestCase {
        var $mPPNodeCount = 0;
        var $mOptions;
 
-       function setUp() {
+       protected function setUp() {
                global $wgParserConf;
                $this->mOptions = new ParserOptions();
                $name = isset( $wgParserConf['preprocessorClass'] ) ? $wgParserConf['preprocessorClass'] : 'Preprocessor_DOM';
index f019ad6..f23f06d 100644 (file)
@@ -7,15 +7,11 @@
 class SearchEngineTest extends MediaWikiTestCase {
        protected $search, $pageList;
 
-       function tearDown() {
-               unset( $this->search );
-       }
-
        /**
         * Checks for database type & version.
         * Will skip current test if DB does not support search.
         */
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                // Search tests require MySQL or SQLite with FTS
                # Get database type and version
@@ -32,6 +28,10 @@ class SearchEngineTest extends MediaWikiTestCase {
                $this->search = new $searchType( $this->db );
        }
 
+       protected function tearDown() {
+               unset( $this->search );
+       }
+
        function pageExists( $title ) {
                return false;
        }
index 6e49a9a..7d867bc 100644 (file)
@@ -19,7 +19,11 @@ class MockSearch extends SearchEngine {
  * @group Search
  */
 class SearchUpdateTest extends MediaWikiTestCase {
-       static $searchType;
+
+       protected function setUp() {
+               parent::setUp();
+               $this->setMwGlobals( 'wgSearchType', 'MockSearch' );
+       }
 
        function update( $text, $title = 'Test', $id = 1 ) {
                $u = new SearchUpdate( $id, $title, $text );
@@ -33,19 +37,6 @@ class SearchUpdateTest extends MediaWikiTestCase {
                return $resultText;
        }
 
-       function setUp() {
-               global $wgSearchType;
-
-               self::$searchType  = $wgSearchType;
-               $wgSearchType = 'MockSearch';
-       }
-
-       function tearDown() {
-               global $wgSearchType;
-
-               $wgSearchType = self::$searchType;
-       }
-
        function testUpdateText() {
                $this->assertEquals(
                        'test',
index 2e4f4b0..f102309 100644 (file)
@@ -14,7 +14,7 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
         */
        protected $rc;
 
-       function setUp() {
+       protected function setUp() {
        }
 
        /** helper to test SpecialRecentchanges::buildMainQueryConds() */
@@ -120,7 +120,7 @@ class SpecialRecentchangesTest extends MediaWikiTestCase {
         * Provides associated namespaces to test recent changes
         * namespaces association filtering.
         */
-       public function provideNamespacesAssociations() {
+       public static function provideNamespacesAssociations() {
                return array( # (NS => Associated_NS)
                        array( NS_MAIN, NS_TALK),
                        array( NS_TALK, NS_MAIN),
index 20e42a6..b2063eb 100644 (file)
@@ -10,9 +10,6 @@
 class SpecialSearchTest extends MediaWikiTestCase {
        private $search;
 
-       function setUp() { }
-       function tearDown() { }
-
        /**
         * @covers SpecialSearch::load
         * @dataProvider provideSearchOptionsTests
index 3093334..59663ba 100644 (file)
@@ -6,7 +6,7 @@
  */
 class UploadFromUrlTest extends ApiTestCase {
 
-       public function setUp() {
+       protected function setUp() {
                global $wgEnableUploads, $wgAllowCopyUploads, $wgAllowAsyncCopyUploads;
                parent::setUp();
 
index 66fafaa..857aef5 100644 (file)
@@ -8,7 +8,7 @@ class UploadStashTest extends MediaWikiTestCase {
         */
        public static $users;
 
-       public function setUp() {
+       protected function setUp() {
                parent::setUp();
 
                // Setup a file for bug 29408
@@ -31,6 +31,18 @@ class UploadStashTest extends MediaWikiTestCase {
                );
        }
 
+       protected function tearDown() {
+               if ( file_exists( $this->bug29408File . "." ) ) {
+                       unlink( $this->bug29408File . "." );
+               }
+
+               if ( file_exists( $this->bug29408File ) ) {
+                       unlink( $this->bug29408File );
+               }
+
+               parent::tearDown();
+       }
+
        public function testBug29408() {
                global $wgUser;
                $wgUser = self::$users['uploader']->user;
@@ -62,16 +74,4 @@ class UploadStashTest extends MediaWikiTestCase {
                $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test', 'wpSessionKey' => 'foo') );
                $this->assertTrue( UploadFromStash::isValidRequest($request), 'Check key precedence' );
        }
-
-       public function tearDown() {
-               parent::tearDown();
-
-               if( file_exists( $this->bug29408File . "." ) ) {
-                       unlink( $this->bug29408File . "." );
-               }
-
-               if( file_exists( $this->bug29408File ) ) {
-                       unlink( $this->bug29408File );
-               }
-       }
 }
index 6948f5b..d757734 100644 (file)
@@ -6,7 +6,7 @@ class UploadTest extends MediaWikiTestCase {
        protected $upload;
 
 
-       function setUp() {
+       protected function setUp() {
                global $wgHooks;
                parent::setUp();
 
@@ -17,7 +17,7 @@ class UploadTest extends MediaWikiTestCase {
                };
        }
 
-       function tearDown() {
+       protected function tearDown() {
                global $wgHooks;
                $wgHooks = $this->hooks;
        }
@@ -27,7 +27,7 @@ class UploadTest extends MediaWikiTestCase {
         * First checks the return code
         * of UploadBase::getTitle() and then the actual returned title
         * 
-        * @dataProvider dataTestTitleValidation
+        * @dataProvider provideTestTitleValidation
         */
        public function testTitleValidation( $srcFilename, $dstFilename, $code, $msg ) {
                /* Check the result code */
@@ -46,7 +46,7 @@ class UploadTest extends MediaWikiTestCase {
        /**
         * Test various forms of valid and invalid titles that can be supplied.
         */
-       public function dataTestTitleValidation() {
+       public static function provideTestTitleValidation() {
                return array(
                        /* Test a valid title */
                        array( 'ValidTitle.jpg', 'ValidTitle.jpg', UploadBase::OK, 
index 3a648de..2679088 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageAmTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Am' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index b23e053..84507c5 100644 (file)
@@ -8,10 +8,10 @@
 class LanguageArTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Ar' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 735ccc6..3135ca8 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageBeTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Be' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 765cdb8..11aacb6 100644 (file)
@@ -3,10 +3,10 @@
 class LanguageBeTaraskTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Be-tarask' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index e1e2a13..00f4e13 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageBhTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Bh' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index b6631c0..39391af 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageBsTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Bs' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index dda29f9..862de52 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageCsTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'cs' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index f8186d7..5d5d60c 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageCuTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'cu' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index e9f9e41..406a943 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageCyTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'cy' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index ab7f931..516b9ee 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageDsbTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'dsb' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 8538744..0a29028 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageFrTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'fr' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index fbd9f11..9535cb1 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageGaTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'ga' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 24574bd..e6bfdd7 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageGdTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'gd' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 3d298b9..18cf225 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageGvTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'gv' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 7833da7..6205320 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageHeTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'he' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index ead9e02..bb3b5fa 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageHiTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Hi' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 4f1c66b..6f0ca1b 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageHrTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'hr' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 803c772..d336e81 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageHsbTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'hsb' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index adbd37e..3181868 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageHuTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Hu' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 7990bdf..2885707 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageHyTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'hy' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index ab88946..78ff445 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageKshTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'ksh' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 0fd9167..60b4945 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageLnTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'ln' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 0d7c7d3..821e028 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageLtTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Lt' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 0636da5..bb0dc6c 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageLvTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'lv' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 06b5654..d6ac643 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageMgTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'mg' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index cf5ec3d..21a9e41 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageMkTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'mk' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 8c4b0b2..9af2389 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageMlTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Ml' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 533e590..4f208d9 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageMoTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'mo' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 421bb38..4d25347 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageMtTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'mt' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index cf979cd..c8cfbb6 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageNlTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Nl' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index ea39362..1e70997 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageNsoTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'nso' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index e56d4b7..a543640 100644 (file)
@@ -9,10 +9,10 @@
 class LanguagePlTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'pl' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 5270f6f..9bf01a4 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageRoTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'ro' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 7a1f193..189a96c 100644 (file)
 class LanguageRuTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'ru' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 065ec29..51cfd2f 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageSeTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'se' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 931c82f..62f2775 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageSgsTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Sgs' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index b8169ae..1d8ae7c 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageShTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'sh' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 4cfd840..25823cf 100644 (file)
 class LanguageSkTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'sk' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index c1f7569..76de0fc 100644 (file)
 class LanguageSlTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'sl' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index b7e72e9..cf14477 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageSmaTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'sma' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index d44ecf8..7be4589 100644 (file)
@@ -19,10 +19,10 @@ class LanguageSrTest extends MediaWikiTestCase {
        /* Language object. Initialized before each test */
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'sr' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index bfb45c7..621c891 100644 (file)
@@ -7,10 +7,10 @@ class LanguageTest extends MediaWikiTestCase {
         */
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'en' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 4bfaa00..175cdb9 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageTiTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Ti' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index a1facd1..e03531f 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageTlTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Tl' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index bda4c9d..a3cacc2 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageTrTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Tr' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 60fafb0..2b6f707 100644 (file)
 class LanguageUkTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Uk' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 7238728..0314649 100644 (file)
@@ -19,10 +19,10 @@ class LanguageUzTest extends MediaWikiTestCase {
        /* Language object. Initialized before each test */
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'uz' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index 172f19b..08312ce 100644 (file)
@@ -9,10 +9,10 @@
 class LanguageWaTest extends MediaWikiTestCase {
        private $lang;
 
-       function setUp() {
+       protected function setUp() {
                $this->lang = Language::factory( 'Wa' );
        }
-       function tearDown() {
+       protected function tearDown() {
                unset( $this->lang );
        }
 
index d134438..d9b651f 100644 (file)
@@ -72,7 +72,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase {
         *
         * Clears $wgUser, and reports errors from addDBData to PHPUnit
         */
-       public function setUp() {
+       protected function setUp() {
                global $wgUser;
 
                parent::setUp();
index a7609f1..8afcbf7 100644 (file)
@@ -74,7 +74,7 @@ class TextPassDumperTest extends DumpTestCase {
 
        }
 
-       public function setUp() {
+       protected function setUp() {
                parent::setUp();
 
                // Since we will restrict dumping by page ranges (to allow
index 925e277..64374f8 100644 (file)
@@ -65,7 +65,7 @@ class BackupDumperPageTest extends DumpTestCase {
 
        }
 
-       public function setUp() {
+       protected function setUp() {
                parent::setUp();
 
                // Since we will restrict dumping by page ranges (to allow
index 912d760..89337f4 100644 (file)
@@ -33,13 +33,13 @@ class SideBarTest extends MediaWikiLangTestCase {
                }
        }
 
-       function setUp() {
+       protected function setUp() {
                parent::setUp();
                $this->initMessagesHref();
                $this->skin = new SkinTemplate();
                $this->skin->getContext()->setLanguage( Language::factory( 'en' ) );
        }
-       function tearDown() {
+       protected function tearDown() {
                parent::tearDown();
                $this->skin = null;
        }
index f263811..843aaf9 100644 (file)
@@ -15,7 +15,7 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                return true;
        }
 
-       function setUp() {
+       protected function setUp() {
                global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc,
                          $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
                          $wgNamespaceAliases, $wgNamespaceProtection, $parserMemc;
@@ -79,7 +79,7 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                FileBackendGroup::destroySingleton();
        }
 
-       public function tearDown() {
+       protected function tearDown() {
                foreach ( $this->savedGlobals as $var => $val ) {
                        $GLOBALS[$var] = $val;
                }