r5474 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5473‎ | r5474 | r5475 >
Date:20:56, 24 September 2004
Author:wmahan
Status:old
Tags:
Comment:
Add tests for subpages (+ an option to enable them), images,
more template cases, definition lists/indentation, and
preformatted text.
Modified paths:
  • /trunk/phase3/maintenance/parserTests.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -8,6 +8,7 @@
99 # (default) generate HTML output
1010 # pst apply pre-save transform
1111 # msg apply message transform
 12+# subpage enable subpages (disabled by default)
1213 #
1314 # Tests can be disabled with the '!!disabled' flag.
1415 #
@@ -15,6 +16,14 @@
1617 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
1718 # where '/' denotes a newline.
1819
 20+# This is the standard article assumed to exist.
 21+!! article
 22+Main Page
 23+!! text
 24+blah blah
 25+!! endarticle
 26+
 27+
1928 ###
2029 ### Basic tests
2130 ###
@@ -143,7 +152,7 @@
144153 ### comment test cases
145154 ###
146155 !! test
147 -comment test 1
 156+Comment test 1
148157 !! input
149158 <!-- comment 1 --> asdf
150159 <!-- comment 2 -->
@@ -154,7 +163,7 @@
155164 !! end
156165
157166 !! test
158 -comment test 2
 167+Comment test 2
159168 !! input
160169 asdf
161170 <!-- comment 1 -->
@@ -166,7 +175,7 @@
167176 !! end
168177
169178 !! test
170 -comment test 3
 179+Comment test 3
171180 !! input
172181 asdf
173182 <!-- comment 1 -->
@@ -179,7 +188,7 @@
180189 !! end
181190
182191 !! test
183 -comment test 4
 192+Comment test 4
184193 !! input
185194 asdf<!-- comment 1 -->jkl
186195 !! result
@@ -187,7 +196,65 @@
188197 </p>
189198 !! end
190199
 200+!! test
 201+Comment spacing
 202+!! input
 203+a
 204+ <!-- foo --> b <!-- bar -->
 205+c
 206+!! result
 207+<p>a
 208+</p>
 209+<pre> b
 210+</pre>
 211+<p>c
 212+</p>
 213+!! end
 214+
191215 ###
 216+### Preformatted text
 217+###
 218+!! test
 219+Preformatted text
 220+!! input
 221+ This is some
 222+ Preformatted text
 223+ With ''italic''
 224+ And '''bold'''
 225+ And a [[Main Page|link]]
 226+!! result
 227+<pre>This is some
 228+Preformatted text
 229+With <i>italic</i>
 230+And <b>bold</b>
 231+And a <a href="https://www.mediawiki.org/wiki/Main_Page" title="Main Page">link</a>
 232+</pre>
 233+!! end
 234+
 235+###
 236+### Definition list
 237+###
 238+!! test
 239+Simple definition
 240+!! input
 241+; name : Definition
 242+!! result
 243+<dl><dt> name&nbsp;</dt><dd> Definition
 244+</dd></dl>
 245+
 246+!! end
 247+
 248+!! test
 249+Simple definition
 250+!! input
 251+: Indented text
 252+!! result
 253+<dl><dd> Indented text
 254+</dd></dl>
 255+
 256+!! end
 257+
 258+###
192259 ### External links
193260 ###
194261 !! test
@@ -529,12 +596,6 @@
530597 ###
531598 ### Internal links
532599 ###
533 -!! article
534 -Main Page
535 -!! text
536 -blah blah
537 -!! endarticle
538 -
539600 !! test
540601 Plain link, capitalized
541602 !! input
@@ -908,6 +969,21 @@
909970 !! end
910971
911972
 973+!!article
 974+Template:paramtest2
 975+!! text
 976+including another template, {{paramtest|param={{{arg}}}}}
 977+!! endarticle
 978+
 979+!! test
 980+Template passing argument to another template
 981+!! input
 982+{{paramtest2|arg='hmm'}}
 983+!! result
 984+<p>including another template, This is a test template with parameter 'hmm'
 985+</p>
 986+!! end
 987+
912988 !! article
913989 Template:Linktest2
914990 !! text
@@ -923,6 +999,7 @@
9241000 </p>
9251001 !! end
9261002
 1003+
9271004 !! article
9281005 Template:loop1
9291006 !! text
@@ -978,6 +1055,7 @@
9791056 {{thistemplatedoesnotexist}}
9801057 !! end
9811058
 1059+
9821060 !! test
9831061 pre-save transform: subst magic variables
9841062 !! options
@@ -988,6 +1066,17 @@
9891067 MediaWiki
9901068 !! end
9911069
 1070+# This is bug 89, which I fixed. -- wtm
 1071+!! test
 1072+pre-save transform: subst: templates with parameters
 1073+!! options
 1074+pst
 1075+!! input
 1076+{{subst:paramtest|param="something else"}}
 1077+!! result
 1078+This is a test template with parameter "something else"
 1079+!! end
 1080+
9921081 ###
9931082 ### Message transform tests
9941083 ###
@@ -1011,11 +1100,99 @@
10121101 ''test''
10131102 !! end
10141103
 1104+###
 1105+### Images
 1106+###
 1107+!! test
 1108+Simple image
 1109+!! input
 1110+[[Image: test]]
 1111+!! result
 1112+<p><a href="https://www.mediawiki.org/wiki/Image:Test" class="image" title="Image: test"><img src="/%7Ewmahan/phase3/images/0/0c/Test" alt="Image: test" /></a>
 1113+</p>
 1114+!! end
 1115+
 1116+!! test
 1117+Right-aligned image
 1118+!! input
 1119+[[Image:test|right]]
 1120+!! result
 1121+<div class="floatright"><span><a href="https://www.mediawiki.org/wiki/Image:Test" class="image" title="right"><img src="/%7Ewmahan/phase3/images/0/0c/Test" alt="right" /></a></span></div>
 1122+
 1123+!! end
 1124+
 1125+!! test
 1126+Image with caption
 1127+!! input
 1128+[[Image:test|right|Caption text]]
 1129+!! result
 1130+<div class="floatright"><span><a href="https://www.mediawiki.org/wiki/Image:Test" class="image" title="Caption text"><img src="/%7Ewmahan/phase3/images/0/0c/Test" alt="Caption text" /></a></span></div>
 1131+
 1132+!! end
 1133+
 1134+!! test
 1135+Image with frame and link
 1136+!! input
 1137+[[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
 1138+!! result
 1139+<div class="thumb tleft"><div style="width:202px;"><a href="https://www.mediawiki.org/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="https://www.mediawiki.org/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
 1140+
 1141+!! end
 1142+
 1143+!! test
 1144+Link to image page
 1145+!! input
 1146+[[:Image:test]]
 1147+!! result
 1148+<p><a href="https://www.mediawiki.org/wiki/Image:Test" title="Image:Test">Image:test</a>
 1149+</p>
 1150+!! end
 1151+
 1152+###
 1153+### Subpages
 1154+###
 1155+!! article
 1156+Parser test/subpage
 1157+!! text
 1158+foo
 1159+!! endarticle
 1160+
 1161+!! test
 1162+Subpage link
 1163+!! options
 1164+subpage
 1165+!! input
 1166+[[/subpage]]
 1167+!! result
 1168+<p><a href="https://www.mediawiki.org/wiki/Parser_test/subpage" title="Parser test/subpage">/subpage</a>
 1169+</p>
 1170+!! end
 1171+
 1172+!! test
 1173+Subpage noslash link
 1174+!! options
 1175+subpage
 1176+!!input
 1177+[[/subpage/]]
 1178+!! result
 1179+<p><a href="https://www.mediawiki.org/wiki/Parser_test/subpage" title="Parser test/subpage">subpage</a>
 1180+</p>
 1181+!! end
 1182+
 1183+# bug 561: it would be nice if this linked to /subpage -- wtm
 1184+!! test
 1185+Disabled subpages
 1186+!! input
 1187+[[/subpage]]
 1188+!! result
 1189+<p><a href="https://www.mediawiki.org/index.php?title=Subpage&amp;action=edit" class="new" title="Subpage">subpage</a>
 1190+</p>
 1191+!! end
 1192+
10151193 TODO:
1016 -more templates
1017 -tables
1018 -images
1019 -subpages
 1194+more images
 1195+more tables
 1196+math
10201197 character entities
10211198 and much more
10221199
Index: trunk/phase3/maintenance/parserTests.php
@@ -177,10 +177,18 @@
178178 function runTest( $desc, $input, $result, $opts ) {
179179 print "Running test $desc... ";
180180
181 - $this->setupGlobals();
 181+ $this->setupGlobals($opts);
182182
183183 $user =& new User();
184184 $options =& ParserOptions::newFromUser( $user );
 185+
 186+ if (preg_match('/math/i', $opts)) {
 187+ # XXX this should probably be done by the ParserOptions
 188+ require_once('Math.php');
 189+
 190+ $options->setUseTex(true);
 191+ }
 192+
185193 $parser =& new Parser();
186194 $title =& Title::makeTitle( NS_MAIN, 'Parser_test' );
187195
@@ -224,7 +232,7 @@
225233 *
226234 * @access private
227235 */
228 - function setupGlobals() {
 236+ function setupGlobals($opts = '') {
229237 $settings = array(
230238 'wgServer' => 'http://localhost',
231239 'wgScript' => '/index.php',
@@ -237,6 +245,7 @@
238246
239247 'wgLoadBalancer' => LoadBalancer::newFromParams( $GLOBALS['wgDBservers'] ),
240248 'wgLang' => new LanguageUtf8(),
 249+ 'wgNamespacesWithSubpages' => array( 0 => preg_match('/subpage/i', $opts)),
241250 );
242251 $this->savedGlobals = array();
243252 foreach( $settings as $var => $val ) {

Status & tagging log