Fix @covers for (non-integration) parser tests
authorTim Starling <tstarling@wikimedia.org>
Mon, 27 Feb 2017 04:44:31 +0000 (15:44 +1100)
committerTim Starling <tstarling@wikimedia.org>
Mon, 27 Feb 2017 04:47:56 +0000 (15:47 +1100)
You have to allow tests to cover private Parser methods that they
execute. Private methods will never have separate tests.

Change-Id: Ic842e2be4675f505dc26d1d3e1dd9000401df46c

tests/phpunit/includes/parser/ParserMethodsTest.php
tests/phpunit/includes/parser/ParserPreloadTest.php
tests/phpunit/includes/parser/TagHooksTest.php

index 5e00384..ae58d1c 100644 (file)
@@ -2,8 +2,8 @@
 
 /**
  * @group Database
+ * @covers Parser
  */
-
 class ParserMethodsTest extends MediaWikiLangTestCase {
 
        public static function providePreSaveTransform() {
@@ -19,7 +19,6 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
 
        /**
         * @dataProvider providePreSaveTransform
-        * @covers Parser::preSaveTransform
         */
        public function testPreSaveTransform( $text, $expected ) {
                global $wgParser;
@@ -63,7 +62,6 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
 
        /**
         * @dataProvider provideStripOuterParagraph
-        * @covers Parser::stripOuterParagraph
         */
        public function testStripOuterParagraph( $text, $expected ) {
                $this->assertEquals( $expected, Parser::stripOuterParagraph( $text ) );
@@ -73,7 +71,6 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
         * @expectedException MWException
         * @expectedExceptionMessage Parser state cleared while parsing.
         *  Did you call Parser::parse recursively?
-        * @covers Parser::lock
         */
        public function testRecursiveParse() {
                global $wgParser;
@@ -90,9 +87,6 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
                return 'bar';
        }
 
-       /**
-        * @covers Parser::callParserFunction
-        */
        public function testCallParserFunction() {
                global $wgParser;
 
@@ -111,7 +105,7 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * @covers Parser::parse
+        * @covers Parser
         * @covers ParserOutput::getSections
         */
        public function testGetSections() {
@@ -155,8 +149,6 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
 
        /**
         * @dataProvider provideNormalizeLinkUrl
-        * @covers Parser::normalizeLinkUrl
-        * @covers Parser::normalizeUrlComponent
         */
        public function testNormalizeLinkUrl( $explanation, $url, $expected ) {
                $this->assertEquals( $expected, Parser::normalizeLinkUrl( $url ), $explanation );
index 414ab8f..7707395 100644 (file)
@@ -2,6 +2,30 @@
 /**
  * Basic tests for Parser::getPreloadText
  * @author Antoine Musso
+ *
+ * @covers Parser
+ * @covers StripState
+ *
+ * @covers Preprocessor_DOM
+ * @covers PPDStack
+ * @covers PPDStackElement
+ * @covers PPDPart
+ * @covers PPFrame_DOM
+ * @covers PPTemplateFrame_DOM
+ * @covers PPCustomFrame_DOM
+ * @covers PPNode_DOM
+ *
+ * @covers Preprocessor_Hash
+ * @covers PPDStack_Hash
+ * @covers PPDStackElement_Hash
+ * @covers PPDPart_Hash
+ * @covers PPFrame_Hash
+ * @covers PPTemplateFrame_Hash
+ * @covers PPCustomFrame_Hash
+ * @covers PPNode_Hash_Tree
+ * @covers PPNode_Hash_Text
+ * @covers PPNode_Hash_Array
+ * @covers PPNode_Hash_Attr
  */
 class ParserPreloadTest extends MediaWikiTestCase {
        /**
@@ -37,16 +61,10 @@ class ParserPreloadTest extends MediaWikiTestCase {
                unset( $this->title );
        }
 
-       /**
-        * @covers Parser::getPreloadText
-        */
        public function testPreloadSimpleText() {
                $this->assertPreloaded( 'simple', 'simple' );
        }
 
-       /**
-        * @covers Parser::getPreloadText
-        */
        public function testPreloadedPreIsUnstripped() {
                $this->assertPreloaded(
                        '<pre>monospaced</pre>',
@@ -55,9 +73,6 @@ class ParserPreloadTest extends MediaWikiTestCase {
                );
        }
 
-       /**
-        * @covers Parser::getPreloadText
-        */
        public function testPreloadedNowikiIsUnstripped() {
                $this->assertPreloaded(
                        '<nowiki>[[Dummy title]]</nowiki>',
index 2a4a4ec..12936ee 100644 (file)
@@ -3,6 +3,30 @@
 /**
  * @group Database
  * @group Parser
+ *
+ * @covers Parser
+ * @covers StripState
+ *
+ * @covers Preprocessor_DOM
+ * @covers PPDStack
+ * @covers PPDStackElement
+ * @covers PPDPart
+ * @covers PPFrame_DOM
+ * @covers PPTemplateFrame_DOM
+ * @covers PPCustomFrame_DOM
+ * @covers PPNode_DOM
+ *
+ * @covers Preprocessor_Hash
+ * @covers PPDStack_Hash
+ * @covers PPDStackElement_Hash
+ * @covers PPDPart_Hash
+ * @covers PPFrame_Hash
+ * @covers PPTemplateFrame_Hash
+ * @covers PPCustomFrame_Hash
+ * @covers PPNode_Hash_Tree
+ * @covers PPNode_Hash_Text
+ * @covers PPNode_Hash_Array
+ * @covers PPNode_Hash_Attr
  */
 class TagHookTest extends MediaWikiTestCase {
        public static function provideValidNames() {
@@ -21,7 +45,6 @@ class TagHookTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideValidNames
-        * @covers Parser::setHook
         */
        public function testTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;
@@ -41,7 +64,6 @@ class TagHookTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideBadNames
         * @expectedException MWException
-        * @covers Parser::setHook
         */
        public function testBadTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;
@@ -58,7 +80,6 @@ class TagHookTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideValidNames
-        * @covers Parser::setFunctionTagHook
         */
        public function testFunctionTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;
@@ -78,7 +99,6 @@ class TagHookTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideBadNames
         * @expectedException MWException
-        * @covers Parser::setFunctionTagHook
         */
        public function testBadFunctionTagHooks( $tag ) {
                global $wgParserConf, $wgContLang;