From 302e9e48f647918ea2a21108a63b32bd2b2f9286 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sun, 2 Nov 2014 21:08:43 +0100 Subject: [PATCH] Parser tests for page status indicators https://www.mediawiki.org/wiki/Help:Page_status_indicators Change-Id: Ic461fe889a3f8ef9f332019f72cfb732c0ec1eca --- tests/parser/parserTest.inc | 8 ++ tests/parser/parserTests.txt | 77 +++++++++++++++++++ .../phpunit/includes/parser/NewParserTest.php | 8 ++ 3 files changed, 93 insertions(+) diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index e18c22b709..1cffa20c09 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -643,6 +643,14 @@ class ParserTest { $out = "$title\n$out"; } + if ( isset( $opts['showindicators'] ) ) { + $indicators = ''; + foreach ( $output->getIndicators() as $id => $content ) { + $indicators .= "$id=$content\n"; + } + $out = $indicators . $out; + } + if ( isset( $opts['ill'] ) ) { $out = implode( ' ', $output->getLanguageLinks() ); } elseif ( isset( $opts['cat'] ) ) { diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index c65e8d7ba5..2b7f4cdb04 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -26,6 +26,7 @@ # php php-only test (not run by the parsoid parser unless # the test includes an html/parsoid section) # showtitle make the first line the title +# showindicators make the first lines the page status indicators # comment run through Linker::formatComment() instead of main parser # local format section links in edit comment text as local links # notoc disable table of contents @@ -19143,6 +19144,82 @@ this is not the the title

!! end +!! test +Page status indicators: Empty name is invalid +!! options +showindicators +!! wikitext + + +!! html +

Error: Page status indicators' name attribute must not be empty. +Error: Page status indicators' name attribute must not be empty. +

+!! end + +!! test +Page status indicators: Weird syntaxes that are okay +!! options +showindicators +!! wikitext + + +!! html +empty= +name= +


+

+!! end + +!! test +Page status indicators: Torture test +!! options +showindicators +!! wikitext +hello world +[[Main Page]] +[[File:Foobar.jpg|25px|link=]] +[[File:Foobar.jpg|25px]] +* foo +* bar +foo + Preformatted +
Broken tag +{| class=wikitable +| cell +|} +Two + +paragraphs +!! html +01=hello world +02=Main Page +03=Foobar.jpg +04=Foobar.jpg +05=
  • foo
  • +
  • bar
+ +06=foo +07=
Preformatted
+
+08=
Broken tag
+ +09= + +
cell +
+ +10=

Two +

paragraphs +

+


+


+


+


+


+

+!! end + !! test preload: check and !! options diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index ccd7f96220..91aad10c02 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -771,6 +771,14 @@ class NewParserTest extends MediaWikiTestCase { $out = "$title\n$out"; } + if ( isset( $opts['showindicators'] ) ) { + $indicators = ''; + foreach ( $output->getIndicators() as $id => $content ) { + $indicators .= "$id=$content\n"; + } + $out = $indicators . $out; + } + if ( isset( $opts['ill'] ) ) { $out = implode( ' ', $output->getLanguageLinks() ); } elseif ( isset( $opts['cat'] ) ) { -- 2.20.1