2011-01-15 08:35:56 +00:00
< ? php
class PreprocessorTest extends MediaWikiTestCase {
2013-10-22 23:50:38 +00:00
protected $mTitle = 'Page title' ;
protected $mPPNodeCount = 0 ;
/**
* @ var ParserOptions
*/
protected $mOptions ;
/**
* @ var Preprocessor
*/
protected $mPreprocessor ;
2011-01-15 08:35:56 +00:00
2012-10-08 10:56:20 +00:00
protected function setUp () {
2012-10-14 19:34:26 +00:00
global $wgParserConf , $wgContLang ;
2012-10-23 17:02:36 +00:00
parent :: setUp ();
2012-10-14 19:34:26 +00:00
$this -> mOptions = ParserOptions :: newFromUserAndLang ( new User , $wgContLang );
2014-04-24 17:52:09 +00:00
$name = isset ( $wgParserConf [ 'preprocessorClass' ] )
? $wgParserConf [ 'preprocessorClass' ]
: 'Preprocessor_DOM' ;
2011-01-15 08:35:56 +00:00
$this -> mPreprocessor = new $name ( $this );
}
function getStripList () {
2011-01-17 19:54:44 +00:00
return array ( 'gallery' , 'display map' /* Used by Maps, see r80025 CR */ , '/foo' );
2011-01-15 08:35:56 +00:00
}
2013-03-22 02:12:37 +00:00
public static function provideCases () {
2014-04-24 17:52:09 +00:00
// @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
2011-01-15 08:35:56 +00:00
return array (
array ( " Foo " , " <root>Foo</root> " ),
array ( " <!-- Foo --> " , " <root><comment><!-- Foo --></comment></root> " ),
array ( " <!-- Foo --><!-- Bar --> " , " <root><comment><!-- Foo --></comment><comment><!-- Bar --></comment></root> " ),
array ( " <!-- Foo --> <!-- Bar --> " , " <root><comment><!-- Foo --></comment> <comment><!-- Bar --></comment></root> " ),
array ( " <!-- Foo --> \n <!-- Bar --> " , " <root><comment><!-- Foo --></comment> \n <comment><!-- Bar --></comment></root> " ),
array ( " <!-- Foo --> \n <!-- Bar --> \n " , " <root><comment><!-- Foo --></comment> \n <comment> <!-- Bar --> \n </comment></root> " ),
array ( " <!-- Foo --> <!-- Bar --> \n " , " <root><comment><!-- Foo --></comment> <comment><!-- Bar --></comment> \n </root> " ),
array ( " <!-->Bar " , " <root><comment><!-->Bar</comment></root> " ),
array ( " <!-- Comment -- comment " , " <root><comment><!-- Comment -- comment</comment></root> " ),
array ( " == Foo == \n <!-- Bar --> \n == Baz == \n " , " <root><h level= \" 2 \" i= \" 1 \" >== Foo ==</h> \n <comment> <!-- Bar --> \n </comment><h level= \" 2 \" i= \" 2 \" >== Baz ==</h> \n </root> " ),
array ( " <gallery/> " , " <root><ext><name>gallery</name><attr></attr></ext></root> " ),
array ( " Foo <gallery/> Bar " , " <root>Foo <ext><name>gallery</name><attr></attr></ext> Bar</root> " ),
array ( " <gallery></gallery> " , " <root><ext><name>gallery</name><attr></attr><inner></inner><close></gallery></close></ext></root> " ),
array ( " <foo> <gallery></gallery> " , " <root><foo> <ext><name>gallery</name><attr></attr><inner></inner><close></gallery></close></ext></root> " ),
array ( " <foo> <gallery><gallery></gallery> " , " <root><foo> <ext><name>gallery</name><attr></attr><inner><gallery></inner><close></gallery></close></ext></root> " ),
array ( " <noinclude> Foo bar </noinclude> " , " <root><ignore><noinclude></ignore> Foo bar <ignore></noinclude></ignore></root> " ),
2011-01-17 23:12:07 +00:00
array ( " <noinclude> \n { { Foo}} \n </noinclude> " , " <root><ignore><noinclude></ignore> \n <template lineStart= \" 1 \" ><title>Foo</title></template> \n <ignore></noinclude></ignore></root> " ),
array ( " <noinclude> \n { { Foo}} \n </noinclude> \n " , " <root><ignore><noinclude></ignore> \n <template lineStart= \" 1 \" ><title>Foo</title></template> \n <ignore></noinclude></ignore> \n </root> " ),
Preprocessor: Don't allow unclosed extension tags (matching until end of input)
I think it's saner to treat this as invalid syntax, and output the
mismatched tag code verbatim. The current behavior is particularly
annoying for <ref> tags, which often swallow everything afterwards.
This does not affect HTML tags, though. Assuming Tidy is enabled, they
are still auto-closed at the end of the page content.
Related to T17712 and T58306. I think this brings the PHP parser closer
to Parsoid's interpretation.
It reduces performance somewhat in the worst case, though. Testing with
https://phabricator.wikimedia.org/F3245989 (a 1 MB page starting with
3000 opening tags of 15 different types), parsing time rises from
~0.2 seconds to ~1.1 seconds on my setup. We go from O(N) to O(kN),
where N is bytes of input and k is the number of types of tags present
on the page. Maximum k shouldn't exceed 30 or so in reasonable setups
(depends on installed extensions, it's 20 on English Wikipedia).
To consider:
* Should we keep previous behavior for unclosed <includeonly> /
<noinclude>? This would be particularly disruptive for these if
someone relied on the old behavior, and they're already
special-cased in places.
* Unclosed <pre> tags are now treated as HTML tags, and are still
displayed as preformatted text, but without suppressing wikitext
formatting.
Change-Id: Ia2f24dbfb3567c4b0778761585e6c0303d11ddd0
2015-11-24 21:55:24 +00:00
array ( " <gallery>foo bar " , " <root><gallery>foo bar</root> " ),
2011-05-04 14:40:25 +00:00
array ( " < { { foo}}> " , " <root><<template><title>foo</title></template>></root> " ),
array ( " < { { { foo}}}> " , " <root><<tplarg><title>foo</title></tplarg>></root> " ),
2011-01-15 08:35:56 +00:00
array ( " <gallery></gallery</gallery> " , " <root><ext><name>gallery</name><attr></attr><inner></gallery</inner><close></gallery></close></ext></root> " ),
array ( " === Foo === " , " <root><h level= \" 3 \" i= \" 1 \" >=== Foo === </h></root> " ),
array ( " ==<!-- -->= Foo === " , " <root><h level= \" 2 \" i= \" 1 \" >==<comment><!-- --></comment>= Foo === </h></root> " ),
array ( " === Foo ==<!-- -->= " , " <root><h level= \" 1 \" i= \" 1 \" >=== Foo ==<comment><!-- --></comment>= </h></root> " ),
array ( " === Foo ===<!-- --> \n " , " <root><h level= \" 3 \" i= \" 1 \" >=== Foo ===<comment><!-- --></comment></h> \n </root> " ),
array ( " === Foo ===<!-- --> <!-- --> \n " , " <root><h level= \" 3 \" i= \" 1 \" >=== Foo ===<comment><!-- --></comment> <comment><!-- --></comment></h> \n </root> " ),
array ( " == Foo == \n == Bar == \n " , " <root><h level= \" 2 \" i= \" 1 \" >== Foo ==</h> \n <h level= \" 2 \" i= \" 2 \" >== Bar == </h> \n </root> " ),
array ( " =========== " , " <root><h level= \" 5 \" i= \" 1 \" >===========</h></root> " ),
2011-04-23 21:18:22 +00:00
array ( " Foo \n = \n == \n = \n " , " <root>Foo \n = \n == \n = \n </root> " ),
2011-09-12 19:16:22 +00:00
array ( " { { Foo}} " , " <root><template><title>Foo</title></template></root> " ),
2011-01-15 08:35:56 +00:00
array ( " \n { { Foo}} " , " <root> \n <template lineStart= \" 1 \" ><title>Foo</title></template></root> " ),
2013-02-15 10:24:31 +00:00
array ( " { { Foo|bar}} " , " <root><template><title>Foo</title><part><name index= \" 1 \" /><value>bar</value></part></template></root> " ),
array ( " { { Foo|bar}}a " , " <root><template><title>Foo</title><part><name index= \" 1 \" /><value>bar</value></part></template>a</root> " ),
array ( " { { Foo|bar|baz}} " , " <root><template><title>Foo</title><part><name index= \" 1 \" /><value>bar</value></part><part><name index= \" 2 \" /><value>baz</value></part></template></root> " ),
2011-09-12 19:16:22 +00:00
array ( " { { Foo|1=bar}} " , " <root><template><title>Foo</title><part><name>1</name>=<value>bar</value></part></template></root> " ),
array ( " { { Foo|=bar}} " , " <root><template><title>Foo</title><part><name></name>=<value>bar</value></part></template></root> " ),
2013-02-15 10:24:31 +00:00
array ( " { { Foo|bar=baz}} " , " <root><template><title>Foo</title><part><name>bar</name>=<value>baz</value></part></template></root> " ),
2011-10-31 22:21:46 +00:00
array ( " { { Foo| { { bar}}=baz}} " , " <root><template><title>Foo</title><part><name><template><title>bar</title></template></name>=<value>baz</value></part></template></root> " ),
2013-02-15 10:24:31 +00:00
array ( " { { Foo|1=bar|baz}} " , " <root><template><title>Foo</title><part><name>1</name>=<value>bar</value></part><part><name index= \" 1 \" /><value>baz</value></part></template></root> " ),
2011-10-29 21:19:08 +00:00
array ( " { { Foo|1=bar|2=baz}} " , " <root><template><title>Foo</title><part><name>1</name>=<value>bar</value></part><part><name>2</name>=<value>baz</value></part></template></root> " ),
2013-02-15 10:24:31 +00:00
array ( " { { Foo|bar|foo=baz}} " , " <root><template><title>Foo</title><part><name index= \" 1 \" /><value>bar</value></part><part><name>foo</name>=<value>baz</value></part></template></root> " ),
2011-09-12 19:16:22 +00:00
array ( " { { { 1}}} " , " <root><tplarg><title>1</title></tplarg></root> " ),
array ( " { { { 1|}}} " , " <root><tplarg><title>1</title><part><name index= \" 1 \" /><value></value></part></tplarg></root> " ),
array ( " { { { Foo}}} " , " <root><tplarg><title>Foo</title></tplarg></root> " ),
array ( " { { { Foo|}}} " , " <root><tplarg><title>Foo</title><part><name index= \" 1 \" /><value></value></part></tplarg></root> " ),
array ( " { { { Foo|bar|baz}}} " , " <root><tplarg><title>Foo</title><part><name index= \" 1 \" /><value>bar</value></part><part><name index= \" 2 \" /><value>baz</value></part></tplarg></root> " ),
2011-01-15 08:35:56 +00:00
array ( " { <!-- --> { Foo}} " , " <root> { <comment><!-- --></comment> { Foo}}</root> " ),
2011-04-23 21:18:22 +00:00
array ( " { { { { Foobar}}}} " , " <root> { <tplarg><title>Foobar</title></tplarg>}</root> " ),
2011-09-12 19:16:22 +00:00
array ( " { { { { { Foo}} }}} " , " <root><tplarg><title> <template><title>Foo</title></template> </title></tplarg></root> " ),
array ( " { { { { { Foo}}} }} " , " <root><template><title> <tplarg><title>Foo</title></tplarg> </title></template></root> " ),
array ( " { { { { { Foo}}}}} " , " <root><template><title><tplarg><title>Foo</title></tplarg></title></template></root> " ),
array ( " { { { { { Foo}} }}} " , " <root><tplarg><title><template><title>Foo</title></template> </title></tplarg></root> " ),
array ( " { { { { { { Foo}}}}}} " , " <root><tplarg><title><tplarg><title>Foo</title></tplarg></title></tplarg></root> " ),
2011-01-15 08:35:56 +00:00
array ( " { { { { { { Foo}}}}} " , " <root> { <template><title><tplarg><title>Foo</title></tplarg></title></template></root> " ),
array ( " [[[Foo]] " , " <root>[[[Foo]]</root> " ),
2011-09-12 19:16:22 +00:00
array ( " { { Foo|[[[[bar]]|baz]]}} " , " <root><template><title>Foo</title><part><name index= \" 1 \" /><value>[[[[bar]]|baz]]</value></part></template></root> " ), // This test is important, since it means the difference between having the [[ rule stacked or not
2011-01-16 18:20:44 +00:00
array ( " { { Foo|[[[[bar]|baz]]}} " , " <root> { { Foo|[[[[bar]|baz]]}}</root> " ),
2011-01-17 19:54:44 +00:00
array ( " { { Foo|Foo [[[[bar]|baz]]}} " , " <root> { { Foo|Foo [[[[bar]|baz]]}}</root> " ),
array ( " Foo <display map>Bar</display map >Baz " , " <root>Foo <ext><name>display map</name><attr></attr><inner>Bar</inner><close></display map ></close></ext>Baz</root> " ),
array ( " Foo <display map foo>Bar</display map >Baz " , " <root>Foo <ext><name>display map</name><attr> foo</attr><inner>Bar</inner><close></display map ></close></ext>Baz</root> " ),
array ( " Foo <gallery bar= \" baz \" /> " , " <root>Foo <ext><name>gallery</name><attr> bar="baz" </attr></ext></root> " ),
2011-10-31 22:24:26 +00:00
array ( " Foo <gallery bar= \" 1 \" baz=2 /> " , " <root>Foo <ext><name>gallery</name><attr> bar="1" baz=2 </attr></ext></root> " ),
2011-01-17 19:54:44 +00:00
array ( " </foo>Foo<//foo> " , " <root><ext><name>/foo</name><attr></attr><inner>Foo</inner><close><//foo></close></ext></root> " ), # Worth blacklisting IMHO
2013-02-15 10:24:31 +00:00
array ( " { { #ifexpr: ( { { { 1|1}}} = 2) | Foo | Bar }} " , " <root><template><title>#ifexpr: (<tplarg><title>1</title><part><name index= \" 1 \" /><value>1</value></part></tplarg> = 2) </title><part><name index= \" 1 \" /><value> Foo </value></part><part><name index= \" 2 \" /><value> Bar </value></part></template></root> " ),
array ( " { { #if: { { { 1|}}} | Foo | { { Bar}} }} " , " <root><template><title>#if: <tplarg><title>1</title><part><name index= \" 1 \" /><value></value></part></tplarg> </title><part><name index= \" 1 \" /><value> Foo </value></part><part><name index= \" 2 \" /><value> <template><title>Bar</title></template> </value></part></template></root> " ),
array ( " { { #if: { { { 1|}}} | Foo | [[Bar]] }} " , " <root><template><title>#if: <tplarg><title>1</title><part><name index= \" 1 \" /><value></value></part></tplarg> </title><part><name index= \" 1 \" /><value> Foo </value></part><part><name index= \" 2 \" /><value> [[Bar]] </value></part></template></root> " ),
array ( " { { #if: { { { 1|}}} | [[Foo]] | Bar }} " , " <root><template><title>#if: <tplarg><title>1</title><part><name index= \" 1 \" /><value></value></part></tplarg> </title><part><name index= \" 1 \" /><value> [[Foo]] </value></part><part><name index= \" 2 \" /><value> Bar </value></part></template></root> " ),
array ( " { { #if: { { { 1|}}} | 1 | { { #if: { { { 1|}}} | 2 | 3 }} }} " , " <root><template><title>#if: <tplarg><title>1</title><part><name index= \" 1 \" /><value></value></part></tplarg> </title><part><name index= \" 1 \" /><value> 1 </value></part><part><name index= \" 2 \" /><value> <template><title>#if: <tplarg><title>1</title><part><name index= \" 1 \" /><value></value></part></tplarg> </title><part><name index= \" 1 \" /><value> 2 </value></part><part><name index= \" 2 \" /><value> 3 </value></part></template> </value></part></template></root> " ),
array ( " { { { { Foo}} " , " <root> { { <template><title>Foo</title></template></root> " ),
array ( " { { Foobar { { Foo}} { { Bar}} { { Baz}} " , " <root> { { Foobar <template><title>Foo</title></template> <template><title>Bar</title></template> <template><title>Baz</title></template> </root> " ),
array ( " [[Foo]] | " , " <root>[[Foo]] |</root> " ),
array ( " { { Foo|Bar| " , " <root> { { Foo|Bar|</root> " ),
array ( " [[Foo] " , " <root>[[Foo]</root> " ),
array ( " [[Foo|Bar] " , " <root>[[Foo|Bar]</root> " ),
array ( " { { Foo| [[Bar] }} " , " <root> { { Foo| [[Bar] }}</root> " ),
array ( " { { Foo| [[Bar|Baz] }} " , " <root> { { Foo| [[Bar|Baz] }}</root> " ),
array ( " { { Foo|bar=[[baz]}} " , " <root> { { Foo|bar=[[baz]}}</root> " ),
array ( " { { foo| " , " <root> { { foo|</root> " ),
array ( " { { foo|} " , " <root> { { foo|}</root> " ),
array ( " { { foo|} }} " , " <root><template><title>foo</title><part><name index= \" 1 \" /><value>} </value></part></template></root> " ),
array ( " { { foo|bar=|} " , " <root> { { foo|bar=|}</root> " ),
array ( " { { Foo|} Bar= " , " <root> { { Foo|} Bar=</root> " ),
array ( " { { Foo|} Bar=}} " , " <root><template><title>Foo</title><part><name>} Bar</name>=<value></value></part></template></root> " ),
2012-08-27 19:03:15 +00:00
/* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */
2011-01-15 08:35:56 +00:00
);
2014-04-24 17:52:09 +00:00
// @codingStandardsIgnoreEnd
2011-01-15 08:35:56 +00:00
}
2011-10-15 20:21:52 +00:00
/**
* Get XML preprocessor tree from the preprocessor ( which may not be the
* native XML - based one ) .
*
* @ param string $wikiText
* @ return string
*/
2013-10-22 23:50:38 +00:00
protected function preprocessToXml ( $wikiText ) {
2011-10-28 15:02:10 +00:00
if ( method_exists ( $this -> mPreprocessor , 'preprocessToXml' ) ) {
return $this -> normalizeXml ( $this -> mPreprocessor -> preprocessToXml ( $wikiText ) );
}
2012-12-09 02:37:10 +00:00
2011-10-15 20:21:52 +00:00
$dom = $this -> mPreprocessor -> preprocessToObj ( $wikiText );
if ( is_callable ( array ( $dom , 'saveXML' ) ) ) {
return $dom -> saveXML ();
} else {
return $this -> normalizeXml ( $dom -> __toString () );
}
}
/**
* Normalize XML string to the form that a DOMDocument saves out .
*
* @ param string $xml
* @ return string
*/
2013-10-22 23:50:38 +00:00
protected function normalizeXml ( $xml ) {
2011-10-28 15:13:27 +00:00
return preg_replace ( '!<([a-z]+)/>!' , '<$1></$1>' , str_replace ( ' />' , '/>' , $xml ) );
2011-10-15 20:21:52 +00:00
}
2011-01-15 08:35:56 +00:00
/**
* @ dataProvider provideCases
2013-10-22 23:50:38 +00:00
* @ covers Preprocessor_DOM :: preprocessToXml
2011-01-15 08:35:56 +00:00
*/
2013-10-22 23:50:38 +00:00
public function testPreprocessorOutput ( $wikiText , $expectedXml ) {
2011-10-15 20:21:52 +00:00
$this -> assertEquals ( $this -> normalizeXml ( $expectedXml ), $this -> preprocessToXml ( $wikiText ) );
2011-01-15 08:35:56 +00:00
}
2011-01-21 23:03:33 +00:00
/**
* These are more complex test cases taken out of wiki articles .
*/
2013-03-22 02:12:37 +00:00
public static function provideFiles () {
2014-04-24 17:52:09 +00:00
// @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
2011-01-21 23:03:33 +00:00
return array (
2014-03-24 12:51:29 +00:00
array ( " QuoteQuran " ), # http://en.wikipedia.org/w/index.php?title=Template:QuoteQuran/sandbox&oldid=237348988 GFDL + CC BY-SA by Striver
array ( " Factorial " ), # http://en.wikipedia.org/w/index.php?title=Template:Factorial&oldid=98548758 GFDL + CC BY-SA by Polonium
2011-01-21 23:03:33 +00:00
array ( " All_system_messages " ), # http://tl.wiktionary.org/w/index.php?title=Suleras:All_system_messages&oldid=2765 GPL text generated by MediaWiki
2014-03-24 12:51:29 +00:00
array ( " Fundraising " ), # http://tl.wiktionary.org/w/index.php?title=MediaWiki:Sitenotice&oldid=5716 GFDL + CC BY-SA, copied there by Sky Harbor.
2012-05-22 23:56:33 +00:00
array ( " NestedTemplates " ), # bug 27936
2011-01-21 23:03:33 +00:00
);
2014-04-24 17:52:09 +00:00
// @codingStandardsIgnoreEnd
2011-01-21 23:03:33 +00:00
}
/**
* @ dataProvider provideFiles
2013-10-22 23:50:38 +00:00
* @ covers Preprocessor_DOM :: preprocessToXml
2011-01-21 23:03:33 +00:00
*/
2013-10-22 23:50:38 +00:00
public function testPreprocessorOutputFiles ( $filename ) {
2012-08-27 19:03:15 +00:00
$folder = __DIR__ . " /../../../parser/preprocess " ;
2011-01-21 23:03:33 +00:00
$wikiText = file_get_contents ( " $folder / $filename .txt " );
2011-10-15 20:21:52 +00:00
$output = $this -> preprocessToXml ( $wikiText );
2011-01-21 23:03:33 +00:00
$expectedFilename = " $folder / $filename .expected " ;
if ( file_exists ( $expectedFilename ) ) {
2011-10-15 20:21:52 +00:00
$expectedXml = $this -> normalizeXml ( file_get_contents ( $expectedFilename ) );
$this -> assertEquals ( $expectedXml , $output );
2011-01-21 23:03:33 +00:00
} else {
2011-04-23 21:18:50 +00:00
$tempFilename = tempnam ( $folder , " $filename . " );
file_put_contents ( $tempFilename , $output );
$this -> markTestIncomplete ( " File $expectedFilename missing. Output stored as $tempFilename " );
2011-01-21 23:03:33 +00:00
}
}
2011-05-01 21:33:16 +00:00
/**
2015-09-12 13:54:13 +00:00
* Tests from T30642 · https :// phabricator . wikimedia . org / T30642
2011-05-01 21:33:16 +00:00
*/
2013-03-22 02:12:37 +00:00
public static function provideHeadings () {
2014-04-24 17:52:09 +00:00
// @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong
2013-02-15 10:24:31 +00:00
return array ( /* These should become headings: */
2011-05-01 21:33:16 +00:00
array ( " == h ==<!--c1--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment></h></root> " ),
array ( " == h == <!--c1--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment></h></root> " ),
array ( " == h ==<!--c1--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> </h></root> " ),
array ( " == h == <!--c1--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> </h></root> " ),
array ( " == h ==<!--c1--><!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment><comment><!--c2--></comment></h></root> " ),
array ( " == h == <!--c1--><!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment><comment><!--c2--></comment></h></root> " ),
array ( " == h ==<!--c1--><!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment><comment><!--c2--></comment> </h></root> " ),
array ( " == h == <!--c1--><!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment><comment><!--c2--></comment> </h></root> " ),
array ( " == h == <!--c1--> <!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> <comment><!--c2--></comment></h></root> " ),
array ( " == h ==<!--c1--> <!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> <comment><!--c2--></comment> </h></root> " ),
array ( " == h == <!--c1--> <!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> <comment><!--c2--></comment> </h></root> " ),
array ( " == h ==<!--c1--><!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment></h></root> " ),
array ( " == h ==<!--c1--> <!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> <comment><!--c2--></comment><comment><!--c3--></comment></h></root> " ),
array ( " == h ==<!--c1--><!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment><comment><!--c2--></comment> <comment><!--c3--></comment></h></root> " ),
array ( " == h ==<!--c1--> <!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> <comment><!--c2--></comment> <comment><!--c3--></comment></h></root> " ),
array ( " == h == <!--c1--><!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment></h></root> " ),
array ( " == h == <!--c1--> <!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> <comment><!--c2--></comment><comment><!--c3--></comment></h></root> " ),
array ( " == h == <!--c1--><!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment><comment><!--c2--></comment> <comment><!--c3--></comment></h></root> " ),
array ( " == h == <!--c1--> <!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> <comment><!--c2--></comment> <comment><!--c3--></comment></h></root> " ),
array ( " == h ==<!--c1--><!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment> </h></root> " ),
array ( " == h ==<!--c1--> <!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> <comment><!--c2--></comment><comment><!--c3--></comment> </h></root> " ),
array ( " == h ==<!--c1--><!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment><comment><!--c2--></comment> <comment><!--c3--></comment> </h></root> " ),
array ( " == h ==<!--c1--> <!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> <comment><!--c2--></comment> <comment><!--c3--></comment> </h></root> " ),
array ( " == h == <!--c1--><!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment> </h></root> " ),
array ( " == h == <!--c1--> <!--c2--><!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> <comment><!--c2--></comment><comment><!--c3--></comment> </h></root> " ),
array ( " == h == <!--c1--><!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment><comment><!--c2--></comment> <comment><!--c3--></comment> </h></root> " ),
array ( " == h == <!--c1--> <!--c2--> <!--c3--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> <comment><!--c2--></comment> <comment><!--c3--></comment> </h></root> " ),
2013-08-08 23:48:16 +00:00
array ( " == h ==<!--c1--> <!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> <comment><!--c2--></comment></h></root> " ),
array ( " == h == <!--c1--> <!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h == <comment><!--c1--></comment> <comment><!--c2--></comment></h></root> " ),
array ( " == h ==<!--c1--> <!--c2--> " , " <root><h level= \" 2 \" i= \" 1 \" >== h ==<comment><!--c1--></comment> <comment><!--c2--></comment> </h></root> " ),
2011-05-01 21:33:16 +00:00
/* These are not working: */
array ( " == h == x <!--c1--><!--c2--><!--c3--> " , " <root>== h == x <comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment> </root> " ),
array ( " == h ==<!--c1--> x <!--c2--><!--c3--> " , " <root>== h ==<comment><!--c1--></comment> x <comment><!--c2--></comment><comment><!--c3--></comment> </root> " ),
array ( " == h ==<!--c1--><!--c2--><!--c3--> x " , " <root>== h ==<comment><!--c1--></comment><comment><!--c2--></comment><comment><!--c3--></comment> x </root> " ),
);
2014-04-24 17:52:09 +00:00
// @codingStandardsIgnoreEnd
2011-05-01 21:33:16 +00:00
}
/**
* @ dataProvider provideHeadings
2013-10-22 23:50:38 +00:00
* @ covers Preprocessor_DOM :: preprocessToXml
2011-05-01 21:33:16 +00:00
*/
2013-10-23 22:51:31 +00:00
public function testHeadings ( $wikiText , $expectedXml ) {
2011-10-15 20:21:52 +00:00
$this -> assertEquals ( $this -> normalizeXml ( $expectedXml ), $this -> preprocessToXml ( $wikiText ) );
2011-05-01 21:33:16 +00:00
}
2011-01-15 08:35:56 +00:00
}