Add support for running test cases on the Linker::formatComment() mini-parser, so...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 20 Jul 2009 00:20:33 +0000 (00:20 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 20 Jul 2009 00:20:33 +0000 (00:20 +0000)
maintenance/parserTests.inc
maintenance/parserTests.txt

index 214e7fe..182c5c7 100644 (file)
@@ -443,6 +443,7 @@ class ParserTest {
                }
 
                $noxml = (bool)preg_match( '~\\b noxml \\b~x', $opts );
+               $local = (bool)preg_match( '~\\b local \\b~x', $opts );
                $parser = $this->getParser();
                $title =& Title::makeTitle( NS_MAIN, $titleText );
 
@@ -458,6 +459,9 @@ class ParserTest {
                        $section = $matches[1];
                        $replace = $matches[2];
                        $out = $parser->replaceSection( $input, $section, $replace );
+               } elseif( preg_match( '/\\bcomment\\b/i', $opts ) ) {
+                       $linker = $user->getSkin();
+                       $out = $linker->formatComment( $input, $title, $local );
                } else {
                        $output = $parser->parse( $input, $title, $options, true, true, 1337 );
                        $out = $output->getText();
index 12fb459..a2d0ab5 100644 (file)
@@ -21,6 +21,8 @@
 #      language=XXX    set content language to XXX for this test
 #      variant=XXX     set the variant of language for this test (eg zh-tw)
 #      disabled        do not run test
+#   comment    run through Linker::formatComment() instead of main parser
+#   local      format section links in edit comment text as local links
 #
 # For testing purposes, temporary articles can created:
 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
@@ -7342,6 +7344,41 @@ Leading > blockquote syntax
 #
 #
 
+#
+# Edit comments
+#
+
+!! test
+Edit comment with link
+!! options
+comment
+!! input
+I like the [[Main Page]] a lot
+!! result
+I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
+!!end
+
+!! test
+Edit comment with section link (non-local, eg in history list)
+!! options
+comment,title=[[Main Page]]
+!! input
+/* External links */ removed bogus entries
+!! result
+<span class="autocomment"><a href="/wiki/Main_Page#External_links" title="Main Page">→</a>External links: </span> removed bogus entries
+!!end
+
+!! test
+Edit comment with section link (local, eg in diff view)
+!! options
+comment,local,title=[[Main Page]]
+!! input
+/* External links */ removed bogus entries
+!! result
+<span class="autocomment"><a href="#External_links">→</a>External links: </span> removed bogus entries
+!!end
+
+
 TODO:
 more images
 more tables