Merge "Remove (edit) from Special:Tags for non-editinterface users"
[lhc/web/wiklou.git] / tests / phpunit / includes / ExtraParserTest.php
index 46aa6fc..07215c1 100644 (file)
@@ -18,7 +18,7 @@ class ExtraParserTest extends MediaWikiTestCase {
                        'wgAlwaysUseTidy' => false,
                        'wgCleanSignatures' => true,
                ) );
-               
+
                $this->options = ParserOptions::newFromUserAndLang( new User, $contLang );
                $this->options->setTemplateCallback( array( __CLASS__, 'statelessFetchTemplate' ) );
                $this->parser = new Parser;
@@ -30,20 +30,20 @@ class ExtraParserTest extends MediaWikiTestCase {
        function testBug8689() {
                global $wgUser;
                $longLine = '1.' . str_repeat( '1234567890', 100000 ) . "\n";
-               
+
                $t = Title::newFromText( 'Unit test' );
                $options = ParserOptions::newFromUser( $wgUser );
                $this->assertEquals( "<p>$longLine</p>",
                        $this->parser->parse( $longLine, $t, $options )->getText() );
        }
-       
+
        /* Test the parser entry points */
        function testParse() {
                $title = Title::newFromText( __FUNCTION__ );
                $parserOutput = $this->parser->parse( "Test\n{{Foo}}\n{{Bar}}", $title, $this->options );
                $this->assertEquals( "<p>Test\nContent of <i>Template:Foo</i>\nContent of <i>Template:Bar</i>\n</p>", $parserOutput->getText() );
        }
-       
+
        function testPreSaveTransform() {
                global $wgUser;
                $title = Title::newFromText( __FUNCTION__ );
@@ -51,21 +51,21 @@ class ExtraParserTest extends MediaWikiTestCase {
 
                $this->assertEquals( "Test\nContent of ''Template:Foo''\n{{Bar}}", $outputText );
        }
-       
+
        function testPreprocess() {
                $title = Title::newFromText( __FUNCTION__ );
                $outputText = $this->parser->preprocess( "Test\n{{Foo}}\n{{Bar}}", $title, $this->options );
-               
+
                $this->assertEquals( "Test\nContent of ''Template:Foo''\nContent of ''Template:Bar''", $outputText );
        }
-       
+
        /**
         * cleanSig() makes all templates substs and removes tildes
         */
        function testCleanSig() {
                $title = Title::newFromText( __FUNCTION__ );
                $outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
-               
+
                $this->assertEquals( "{{SUBST:Foo}} ", $outputText );
        }
 
@@ -73,23 +73,22 @@ class ExtraParserTest extends MediaWikiTestCase {
         * cleanSig() should do nothing if disabled
         */
        function testCleanSigDisabled() {
-               global $wgCleanSignatures;
-               $wgCleanSignatures = false;
+               $this->setMwGlobals( 'wgCleanSignatures', false );
 
                $title = Title::newFromText( __FUNCTION__ );
                $outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
-               
+
                $this->assertEquals( "{{Foo}} ~~~~", $outputText );
        }
-       
+
        /**
         * cleanSigInSig() just removes tildes
         * @dataProvider provideStringsForCleanSigInSig
         */
        function testCleanSigInSig( $in, $out ) {
-               $this->assertEquals( Parser::cleanSigInSig( $in), $out );
+               $this->assertEquals( Parser::cleanSigInSig( $in ), $out );
        }
-       
+
        public static function provideStringsForCleanSigInSig() {
                return array(
                        array( "{{Foo}} ~~~~", "{{Foo}} " ),
@@ -97,35 +96,35 @@ class ExtraParserTest extends MediaWikiTestCase {
                        array( "~~~~~", "" ),
                );
        }
-       
+
        function testGetSection() {
                $outputText2 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 2 );
                $outputText1 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1 );
-               
+
                $this->assertEquals( "=== Heading 2 ===\nSection 2", $outputText2 );
                $this->assertEquals( "== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2", $outputText1 );
        }
-       
+
        function testReplaceSection() {
                $outputText = $this->parser->replaceSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1, "New section 1" );
-               
+
                $this->assertEquals( "Section 0\nNew section 1\n\n== Heading 3 ==\nSection 3", $outputText );
        }
-       
+
        /**
         * Templates and comments are not affected, but noinclude/onlyinclude is.
         */
        function testGetPreloadText() {
                $title = Title::newFromText( __FUNCTION__ );
                $outputText = $this->parser->getPreloadText( "{{Foo}}<noinclude> censored</noinclude> information <!-- is very secret -->", $title, $this->options );
-               
+
                $this->assertEquals( "{{Foo}} information <!-- is very secret -->", $outputText );
        }
-       
-       static function statelessFetchTemplate( $title, $parser=false ) {
+
+       static function statelessFetchTemplate( $title, $parser = false ) {
                $text = "Content of ''" . $title->getFullText() . "''";
                $deps = array();
-               
+
                return array(
                        'text' => $text,
                        'finalTitle' => $title,
@@ -137,7 +136,7 @@ class ExtraParserTest extends MediaWikiTestCase {
         */
        function testTrackingCategory() {
                $title = Title::newFromText( __FUNCTION__ );
-               $catName =  wfMessage( 'broken-file-category' )->inContentLanguage()->text();
+               $catName = wfMessage( 'broken-file-category' )->inContentLanguage()->text();
                $cat = Title::makeTitleSafe( NS_CATEGORY, $catName );
                $expected = array( $cat->getDBkey() );
                $parserOutput = $this->parser->parse( "[[file:nonexistent]]", $title, $this->options );
@@ -155,4 +154,4 @@ class ExtraParserTest extends MediaWikiTestCase {
                $result = $parserOutput->getCategoryLinks();
                $this->assertEmpty( $result );
        }
- }
+}