X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fparser%2FPreprocessorTest.php;h=345fd0a524d28057083633c5aca1486aa5d18adc;hb=5cb425a62b6eba0161702fe49568d137d7b91c91;hp=7e9c9d46bd952824da285229af977b2b4e2c3f5f;hpb=f644281e16dafaafa62de8e548dd0f54f5b1265e;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php index 7e9c9d46bd..345fd0a524 100644 --- a/tests/phpunit/includes/parser/PreprocessorTest.php +++ b/tests/phpunit/includes/parser/PreprocessorTest.php @@ -1,15 +1,24 @@ mOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang ); - $name = isset( $wgParserConf['preprocessorClass'] ) ? $wgParserConf['preprocessorClass'] : 'Preprocessor_DOM'; + $name = isset( $wgParserConf['preprocessorClass'] ) + ? $wgParserConf['preprocessorClass'] + : 'Preprocessor_DOM'; $this->mPreprocessor = new $name( $this ); } @@ -19,6 +28,7 @@ class PreprocessorTest extends MediaWikiTestCase { } public static function provideCases() { + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong return array( array( "Foo", "Foo" ), array( "", "<!-- Foo -->" ), @@ -106,6 +116,7 @@ class PreprocessorTest extends MediaWikiTestCase { array( "{{Foo|} Bar=}}", "" ), /* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */ ); + // @codingStandardsIgnoreEnd } /** @@ -115,7 +126,7 @@ class PreprocessorTest extends MediaWikiTestCase { * @param string $wikiText * @return string */ - function preprocessToXml( $wikiText ) { + protected function preprocessToXml( $wikiText ) { if ( method_exists( $this->mPreprocessor, 'preprocessToXml' ) ) { return $this->normalizeXml( $this->mPreprocessor->preprocessToXml( $wikiText ) ); } @@ -134,14 +145,15 @@ class PreprocessorTest extends MediaWikiTestCase { * @param string $xml * @return string */ - function normalizeXml( $xml ) { + protected function normalizeXml( $xml ) { return preg_replace( '!<([a-z]+)/>!', '<$1>', str_replace( ' />', '/>', $xml ) ); } /** * @dataProvider provideCases + * @covers Preprocessor_DOM::preprocessToXml */ - function testPreprocessorOutput( $wikiText, $expectedXml ) { + public function testPreprocessorOutput( $wikiText, $expectedXml ) { $this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) ); } @@ -149,19 +161,22 @@ class PreprocessorTest extends MediaWikiTestCase { * These are more complex test cases taken out of wiki articles. */ public static function provideFiles() { + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong return array( - 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 + 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 array( "All_system_messages" ), # http://tl.wiktionary.org/w/index.php?title=Suleras:All_system_messages&oldid=2765 GPL text generated by MediaWiki - array( "Fundraising" ), # http://tl.wiktionary.org/w/index.php?title=MediaWiki:Sitenotice&oldid=5716 GFDL + CC-BY-SA, copied there by Sky Harbor. + array( "Fundraising" ), # http://tl.wiktionary.org/w/index.php?title=MediaWiki:Sitenotice&oldid=5716 GFDL + CC BY-SA, copied there by Sky Harbor. array( "NestedTemplates" ), # bug 27936 ); + // @codingStandardsIgnoreEnd } /** * @dataProvider provideFiles + * @covers Preprocessor_DOM::preprocessToXml */ - function testPreprocessorOutputFiles( $filename ) { + public function testPreprocessorOutputFiles( $filename ) { $folder = __DIR__ . "/../../../parser/preprocess"; $wikiText = file_get_contents( "$folder/$filename.txt" ); $output = $this->preprocessToXml( $wikiText ); @@ -181,6 +196,7 @@ class PreprocessorTest extends MediaWikiTestCase { * Tests from Bug 28642 · https://bugzilla.wikimedia.org/28642 */ public static function provideHeadings() { + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong return array( /* These should become headings: */ array( "== h ==", "== h ==<!--c1-->" ), array( "== h == ", "== h == <!--c1-->" ), @@ -218,12 +234,14 @@ class PreprocessorTest extends MediaWikiTestCase { array( "== h == x ", "== h ==<!--c1--> x <!--c2--><!--c3--> " ), array( "== h == x ", "== h ==<!--c1--><!--c2--><!--c3--> x " ), ); + // @codingStandardsIgnoreEnd } /** * @dataProvider provideHeadings + * @covers Preprocessor_DOM::preprocessToXml */ - function testHeadings( $wikiText, $expectedXml ) { + public function testHeadings( $wikiText, $expectedXml ) { $this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) ); } }