Merge "(bug 37209) Make TextContentTest and WikitextContentTest work in all cases"
[lhc/web/wiklou.git] / tests / phpunit / includes / ExtraParserTest.php
index 903a6d2..ca1615e 100644 (file)
@@ -5,20 +5,21 @@
  */
 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;
+               $contLang = Language::factory( 'en' );
+               $this->setMwGlobals( array(
+                       'wgShowDBErrorBacktrace' => true,
+                       'wgLanguageCode' => 'en',
+                       'wgContLang' => $contLang,
+                       'wgLang' => Language::factory( 'en' ),
+                       'wgMemc' => new EmptyBagOStuff,
+                       'wgAlwaysUseTidy' => false,
+                       'wgCleanSignatures' => true,
+               ) );
                
-               $this->options = new ParserOptions;
+               $this->options = ParserOptions::newFromUserAndLang( new User, $contLang );
                $this->options->setTemplateCallback( array( __CLASS__, 'statelessFetchTemplate' ) );
                $this->parser = new Parser;
 
@@ -27,11 +28,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 +63,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 +74,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 +90,7 @@ class ExtraParserTest extends MediaWikiTestCase {
                $this->assertEquals( Parser::cleanSigInSig( $in), $out );
        }
        
-       function provideStringsForCleanSigInSig() {
+       public static function provideStringsForCleanSigInSig() {
                return array(
                        array( "{{Foo}} ~~~~", "{{Foo}} " ),
                        array( "~~~", "" ),