Parser tests for page status indicators
authorBartosz Dziewoński <matma.rex@gmail.com>
Sun, 2 Nov 2014 20:08:43 +0000 (21:08 +0100)
committerLegoktm <legoktm.wikipedia@gmail.com>
Sun, 29 Mar 2015 22:31:51 +0000 (22:31 +0000)
https://www.mediawiki.org/wiki/Help:Page_status_indicators

Change-Id: Ic461fe889a3f8ef9f332019f72cfb732c0ec1eca

tests/parser/parserTest.inc
tests/parser/parserTests.txt
tests/phpunit/includes/parser/NewParserTest.php

index e18c22b..1cffa20 100644 (file)
@@ -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'] ) ) {
index c65e8d7..2b7f4cd 100644 (file)
@@ -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
 </p>
 !! end
 
+!! test
+Page status indicators: Empty name is invalid
+!! options
+showindicators
+!! wikitext
+<indicator name=" "></indicator>
+<indicator></indicator>
+!! html
+<p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
+<span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
+</p>
+!! end
+
+!! test
+Page status indicators: Weird syntaxes that are okay
+!! options
+showindicators
+!! wikitext
+<indicator name="empty" />
+<indicator name></indicator>
+!! html
+empty=
+name=
+<p><br />
+</p>
+!! end
+
+!! test
+Page status indicators: Torture test
+!! options
+showindicators
+!! wikitext
+<indicator name="01">hello world</indicator>
+<indicator name="02">[[Main Page]]</indicator>
+<indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
+<indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
+<indicator name="05">* foo
+* bar</indicator>
+<indicator name="06"><nowiki>foo</nowiki></indicator>
+<indicator name="07"> Preformatted</indicator>
+<indicator name="08"><div>Broken tag</indicator>
+<indicator name="09">{| class=wikitable
+| cell
+|}</indicator>
+<indicator name="10">Two
+
+paragraphs</indicator>
+!! html
+01=hello world
+02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+03=<img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" />
+04=<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" /></a>
+05=<ul><li> foo</li>
+<li> bar</li></ul>
+
+06=foo
+07=<pre>Preformatted
+</pre>
+08=<div>Broken tag</div>
+
+09=<table class="wikitable">
+<tr>
+<td> cell
+</td></tr></table>
+
+10=<p>Two
+</p><p>paragraphs
+</p>
+<p><br />
+</p><p><br />
+</p><p><br />
+</p><p><br />
+</p><p><br />
+</p>
+!! end
+
 !! test
 preload: check <noinclude> and <includeonly>
 !! options
index ccd7f96..91aad10 100644 (file)
@@ -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'] ) ) {