From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- tests/phpunit/includes/ExtraParserTest.php | 64 +++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) (limited to 'tests/phpunit/includes/ExtraParserTest.php') diff --git a/tests/phpunit/includes/ExtraParserTest.php b/tests/phpunit/includes/ExtraParserTest.php index 5b0aa98b..a9088cb2 100644 --- a/tests/phpunit/includes/ExtraParserTest.php +++ b/tests/phpunit/includes/ExtraParserTest.php @@ -10,11 +10,13 @@ class ExtraParserTest extends MediaWikiTestCase { global $wgContLang; global $wgShowDBErrorBacktrace; global $wgLanguageCode; + global $wgAlwaysUseTidy; $wgShowDBErrorBacktrace = true; $wgLanguageCode = 'en'; $wgContLang = new Language( 'en' ); $wgMemc = new EmptyBagOStuff; + $wgAlwaysUseTidy = false; $this->options = new ParserOptions; $this->options->setTemplateCallback( array( __CLASS__, 'statelessFetchTemplate' ) ); @@ -61,20 +63,48 @@ 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 ); } - + /** - * cleanSigInSig() just removes tildes + * cleanSig() should do nothing if disabled */ - function testCleanSigInSig() { + function testCleanSigDisabled() { + global $wgCleanSignatures; + $oldCleanSignature = $wgCleanSignatures; + $wgCleanSignatures = false; + $title = Title::newFromText( __FUNCTION__ ); - $outputText = $this->parser->cleanSigInSig( "{{Foo}} ~~~~" ); + $outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" ); + + $wgCleanSignatures = $oldCleanSignature; - $this->assertEquals( "{{Foo}} ", $outputText ); + $this->assertEquals( "{{Foo}} ~~~~", $outputText ); + } + + /** + * cleanSigInSig() just removes tildes + * @dataProvider provideStringsForCleanSigInSig + */ + function testCleanSigInSig( $in, $out ) { + $this->assertEquals( Parser::cleanSigInSig( $in), $out ); + } + + function provideStringsForCleanSigInSig() { + return array( + array( "{{Foo}} ~~~~", "{{Foo}} " ), + array( "~~~", "" ), + array( "~~~~~", "" ), + ); } function testGetSection() { @@ -110,4 +140,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 ); + } } -- cgit v1.2.3-54-g00ecf