Merge "Revert "merged master"" into Wikidata
[lhc/web/wiklou.git] / tests / phpunit / includes / ExtraParserTest.php
index 1fdee94..11a6604 100644 (file)
@@ -21,6 +21,8 @@ class ExtraParserTest extends MediaWikiTestCase {
                $this->options = new ParserOptions;
                $this->options->setTemplateCallback( array( __CLASS__, 'statelessFetchTemplate' ) );
                $this->parser = new Parser;
+
+               MagicWord::clearCache();
        }
 
        // Bug 8689 - Long numeric lines kill the parser
@@ -93,12 +95,18 @@ class ExtraParserTest extends MediaWikiTestCase {
        
        /**
         * cleanSigInSig() just removes tildes
+        * @dataProvider provideStringsForCleanSigInSig
         */
-       function testCleanSigInSig() {
-               $title = Title::newFromText( __FUNCTION__ );
-               $outputText = $this->parser->cleanSigInSig( "{{Foo}} ~~~~" );
-               
-               $this->assertEquals( "{{Foo}} ", $outputText );
+       function testCleanSigInSig( $in, $out ) {
+               $this->assertEquals( Parser::cleanSigInSig( $in), $out );
+       }
+       
+       function provideStringsForCleanSigInSig() {
+               return array(
+                       array( "{{Foo}} ~~~~", "{{Foo}} " ),
+                       array( "~~~", "" ),
+                       array( "~~~~~", "" ),
+               );
        }
        
        function testGetSection() {
@@ -134,4 +142,28 @@ class ExtraParserTest extends MediaWikiTestCase {
                        'finalTitle' => $title,
                        'deps' => $deps );
        }
+
+       /**
+        * @group Database
+        */
+       function testTrackingCategory() {
+               $title = Title::newFromText( __FUNCTION__ );
+               $catName =  wfMsgForContent( 'broken-file-category' );
+               $cat = Title::makeTitleSafe( NS_CATEGORY, $catName );
+               $expected = array( $cat->getDBkey() );
+               $parserOutput = $this->parser->parse( "[[file:nonexistent]]" , $title, $this->options );
+               $result = $parserOutput->getCategoryLinks();
+               $this->assertEquals( $expected, $result );
+       }
+
+       /**
+        * @group Database
+        */
+       function testTrackingCategorySpecial() {
+               // Special pages shouldn't have tracking cats.
+               $title = SpecialPage::getTitleFor( 'Contributions' );
+               $parserOutput = $this->parser->parse( "[[file:nonexistent]]" , $title, $this->options );
+               $result = $parserOutput->getCategoryLinks();
+               $this->assertEmpty( $result );
+       }
  }