From: Wil Mahan
Date: Fri, 24 Sep 2004 20:56:45 +0000 (+0000)
Subject: Add tests for subpages (+ an option to enable them), images,
X-Git-Tag: 1.5.0alpha1~1812
X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=0a012f372b1c3af16d97c9e599d30db29ed124e2;p=lhc%2Fweb%2Fwiklou.git
Add tests for subpages (+ an option to enable them), images,
more template cases, definition lists/indentation, and
preformatted text.
---
diff --git a/maintenance/parserTests.php b/maintenance/parserTests.php
index 5670d538af..6e1422ebeb 100644
--- a/maintenance/parserTests.php
+++ b/maintenance/parserTests.php
@@ -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 ) {
diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt
index 8bb33febdf..86e1ae7f06 100644
--- a/maintenance/parserTests.txt
+++ b/maintenance/parserTests.txt
@@ -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.
#
@@ -15,6 +16,14 @@
# !!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
asdf
@@ -154,7 +163,7 @@ comment test 1
!! end
!! test
-comment test 2
+Comment test 2
!! input
asdf
@@ -166,7 +175,7 @@ jkl
!! end
!! test
-comment test 3
+Comment test 3
!! input
asdf
@@ -179,7 +188,7 @@ jkl
!! end
!! test
-comment test 4
+Comment test 4
!! input
asdfjkl
!! result
@@ -187,6 +196,64 @@ asdfjkl
!! end
+!! test
+Comment spacing
+!! input
+a
+ b
+c
+!! result
+a
+
+ b
+
+c
+
+!! end
+
+###
+### Preformatted text
+###
+!! test
+Preformatted text
+!! input
+ This is some
+ Preformatted text
+ With ''italic''
+ And '''bold'''
+ And a [[Main Page|link]]
+!! result
+This is some
+Preformatted text
+With italic
+And bold
+And a link
+
+!! end
+
+###
+### Definition list
+###
+!! test
+Simple definition
+!! input
+; name : Definition
+!! result
+- name
- Definition
+
+
+!! end
+
+!! test
+Simple definition
+!! input
+: Indented text
+!! result
+- Indented text
+
+
+!! 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
+including another template, This is a test template with parameter 'hmm'
+
+!! end
+
!! article
Template:Linktest2
!! text
@@ -923,6 +999,7 @@ Template as link source
!! 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
+
+
+!! end
+
+!! test
+Right-aligned image
+!! input
+[[Image:test|right]]
+!! result
+
+
+!! end
+
+!! test
+Image with caption
+!! input
+[[Image:test|right|Caption text]]
+!! result
+
+
+!! end
+
+!! test
+Image with frame and link
+!! input
+[[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
+!! result
+
+
+!! end
+
+!! test
+Link to image page
+!! input
+[[:Image:test]]
+!! result
+Image:test
+
+!! end
+
+###
+### Subpages
+###
+!! article
+Parser test/subpage
+!! text
+foo
+!! endarticle
+
+!! test
+Subpage link
+!! options
+subpage
+!! input
+[[/subpage]]
+!! result
+/subpage
+
+!! end
+
+!! test
+Subpage noslash link
+!! options
+subpage
+!!input
+[[/subpage/]]
+!! result
+subpage
+
+!! end
+
+# bug 561: it would be nice if this linked to /subpage -- wtm
+!! test
+Disabled subpages
+!! input
+[[/subpage]]
+!! result
+subpage
+
+!! end
+
TODO:
-more templates
-tables
-images
-subpages
+more images
+more tables
+math
character entities
and much more