Add tests for subpages (+ an option to enable them), images,
authorWil Mahan <wmahan@users.mediawiki.org>
Fri, 24 Sep 2004 20:56:45 +0000 (20:56 +0000)
committerWil Mahan <wmahan@users.mediawiki.org>
Fri, 24 Sep 2004 20:56:45 +0000 (20:56 +0000)
more template cases, definition lists/indentation, and
preformatted text.

maintenance/parserTests.php
maintenance/parserTests.txt

index 5670d53..6e1422e 100644 (file)
@@ -177,10 +177,18 @@ class ParserTest {
        function runTest( $desc, $input, $result, $opts ) {
                print "Running test $desc... ";
 
-               $this->setupGlobals();
+               $this->setupGlobals($opts);
 
                $user =& new User();
                $options =& ParserOptions::newFromUser( $user );
+
+               if (preg_match('/math/i', $opts)) {
+                       # XXX this should probably be done by the ParserOptions
+                       require_once('Math.php');
+
+                       $options->setUseTex(true);
+               }
+
                $parser =& new Parser();
                $title =& Title::makeTitle( NS_MAIN, 'Parser_test' );
 
@@ -224,7 +232,7 @@ class ParserTest {
         *
         * @access private
         */
-       function setupGlobals() {
+       function setupGlobals($opts = '') {
                $settings = array(
                        'wgServer' => 'http://localhost',
                        'wgScript' => '/index.php',
@@ -237,6 +245,7 @@ class ParserTest {
                        
                        'wgLoadBalancer' => LoadBalancer::newFromParams( $GLOBALS['wgDBservers'] ),
                        'wgLang' => new LanguageUtf8(),
+                       'wgNamespacesWithSubpages' => array( 0 => preg_match('/subpage/i', $opts)),
                        );
                $this->savedGlobals = array();
                foreach( $settings as $var => $val ) {
index 8bb33fe..86e1ae7 100644 (file)
@@ -8,6 +8,7 @@
 #      (default)       generate HTML output
 #      pst             apply pre-save transform
 #      msg             apply message transform
+#      subpage         enable subpages (disabled by default)
 #
 # Tests can be disabled with the '!!disabled' flag.
 #
 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
 # where '/' denotes a newline.
 
+# This is the standard article assumed to exist.
+!! article
+Main Page
+!! text
+blah blah
+!! endarticle
+
+
 ###
 ### Basic tests
 ###
@@ -143,7 +152,7 @@ nowiki 3
 ### comment test cases
 ###
 !! test
-comment test 1
+Comment test 1
 !! input
 <!-- comment 1 --> asdf
 <!-- comment 2 -->
@@ -154,7 +163,7 @@ comment test 1
 !! end
 
 !! test
-comment test 2
+Comment test 2
 !! input
 asdf
 <!-- comment 1 -->
@@ -166,7 +175,7 @@ jkl
 !! end
 
 !! test
-comment test 3
+Comment test 3
 !! input
 asdf
 <!-- comment 1 -->
@@ -179,7 +188,7 @@ jkl
 !! end
 
 !! test
-comment test 4
+Comment test 4
 !! input
 asdf<!-- comment 1 -->jkl
 !! result
@@ -187,6 +196,64 @@ asdf<!-- comment 1 -->jkl
 </p>
 !! end
 
+!! test
+Comment spacing
+!! input
+a
+ <!-- foo --> b <!-- bar -->
+c
+!! result
+<p>a
+</p>
+<pre> b 
+</pre>
+<p>c
+</p>
+!! end
+
+###
+### Preformatted text
+###
+!! test
+Preformatted text
+!! input
+ This is some
+ Preformatted text
+ With ''italic''
+ And '''bold'''
+ And a [[Main Page|link]]
+!! result
+<pre>This is some
+Preformatted text
+With <i>italic</i>
+And <b>bold</b>
+And a <a href="/wiki/Main_Page" title="Main Page">link</a>
+</pre>
+!! end
+
+###
+### Definition list
+###
+!! test
+Simple definition
+!! input
+; name : Definition
+!! result
+<dl><dt> name&nbsp;</dt><dd> Definition
+</dd></dl>
+
+!! end
+
+!! test
+Simple definition
+!! input
+: Indented text
+!! result
+<dl><dd> Indented text
+</dd></dl>
+
+!! end
+
 ###
 ### External links
 ###
@@ -529,12 +596,6 @@ Nested table
 ###
 ### Internal links
 ###
-!! article
-Main Page
-!! text
-blah blah
-!! endarticle
-
 !! test
 Plain link, capitalized
 !! input
@@ -908,6 +969,21 @@ Template parameter as link source
 !! end
 
 
+!!article
+Template:paramtest2
+!! text
+including another template, {{paramtest|param={{{arg}}}}}
+!! endarticle
+
+!! test
+Template passing argument to another template
+!! input
+{{paramtest2|arg='hmm'}}
+!! result
+<p>including another template, This is a test template with parameter 'hmm'
+</p>
+!! end
+
 !! article
 Template:Linktest2
 !! text
@@ -923,6 +999,7 @@ Template as link source
 </p>
 !! end
 
+
 !! article
 Template:loop1
 !! text
@@ -978,6 +1055,7 @@ PST
 {{thistemplatedoesnotexist}}
 !! end
 
+
 !! test
 pre-save transform: subst magic variables
 !! options
@@ -988,6 +1066,17 @@ PST
 MediaWiki
 !! end
 
+# This is bug 89, which I fixed. -- wtm
+!! test
+pre-save transform: subst: templates with parameters
+!! options
+pst
+!! input
+{{subst:paramtest|param="something else"}}
+!! result
+This is a test template with parameter "something else"
+!! end
+
 ###
 ### Message transform tests
 ###
@@ -1011,11 +1100,99 @@ msg
 ''test''
 !! end
 
+###
+### Images
+###
+!! test
+Simple image
+!! input
+[[Image: test]]
+!! result
+<p><a href="/wiki/Image:Test" class="image" title="Image: test"><img src="/%7Ewmahan/phase3/images/0/0c/Test" alt="Image: test" /></a>
+</p>
+!! end
+
+!! test
+Right-aligned image
+!! input
+[[Image:test|right]]
+!! result
+<div class="floatright"><span><a href="/wiki/Image:Test" class="image" title="right"><img src="/%7Ewmahan/phase3/images/0/0c/Test" alt="right" /></a></span></div>
+
+!! end
+
+!! test
+Image with caption
+!! input
+[[Image:test|right|Caption text]]
+!! result
+<div class="floatright"><span><a href="/wiki/Image:Test" class="image" title="Caption text"><img src="/%7Ewmahan/phase3/images/0/0c/Test" alt="Caption text" /></a></span></div>
+
+!! end
+
+!! test
+Image with frame and link
+!! input
+[[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
+!! result
+<div class="thumb tleft"><div style="width:202px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a test image "><img src="/%7Ewmahan/phase3/images/3/3a/Foobar.jpg" alt="This is a test image " width="200" height="200" /></a>  <div class="thumbcaption" >This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
+
+!! end
+
+!! test
+Link to image page
+!! input
+[[:Image:test]]
+!! result
+<p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
+</p>
+!! end
+
+###
+### Subpages
+###
+!! article
+Parser test/subpage
+!! text
+foo
+!! endarticle
+
+!! test
+Subpage link
+!! options
+subpage
+!! input
+[[/subpage]]
+!! result
+<p><a href="/wiki/Parser_test/subpage" title="Parser test/subpage">/subpage</a>
+</p>
+!! end
+
+!! test
+Subpage noslash link
+!! options
+subpage
+!!input
+[[/subpage/]]
+!! result
+<p><a href="/wiki/Parser_test/subpage" title="Parser test/subpage">subpage</a>
+</p>
+!! end
+
+# bug 561: it would be nice if this linked to /subpage -- wtm
+!! test
+Disabled subpages
+!! input
+[[/subpage]]
+!! result
+<p><a href="/index.php?title=Subpage&amp;action=edit" class="new" title="Subpage">subpage</a>
+</p>
+!! end
+
 TODO:
-more templates
-tables
-images
-subpages
+more images
+more tables
+math
 character entities
 and much more