X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fparser%2FParserMethodsTest.php;h=29af2c28d67cd9a526a9380eb25b6d731a0572f4;hb=5cb425a62b6eba0161702fe49568d137d7b91c91;hp=4ea8fc6c19b19cf07a6b1dee44ff032158432ad6;hpb=5a81ad0e8a698cb3e9c6b513b2003b198d5c00a1;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php index 4ea8fc6c19..29af2c28d6 100644 --- a/tests/phpunit/includes/parser/ParserMethodsTest.php +++ b/tests/phpunit/includes/parser/ParserMethodsTest.php @@ -29,6 +29,42 @@ class ParserMethodsTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $text ); } + public static function provideStripOuterParagraph() { + // This mimics the most common use case (stripping paragraphs generated by the parser). + $message = new RawMessage( "Message text." ); + + return array( + array( + "

Text.

", + "Text.", + ), + array( + "

Text.

", + "

Text.

", + ), + array( + "

Text.\n

\n", + "Text.", + ), + array( + "

Text.

More text.

", + "

Text.

More text.

", + ), + array( + $message->parse(), + "Message text.", + ), + ); + } + + /** + * @dataProvider provideStripOuterParagraph + * @covers Parser::stripOuterParagraph + */ + public function testStripOuterParagraph( $text, $expected ) { + $this->assertEquals( $expected, Parser::stripOuterParagraph( $text ) ); + } + /** * @expectedException MWException * @expectedExceptionMessage Parser state cleared while parsing. Did you call Parser::parse recursively?