Index: trunk/phase3/maintenance/parserTests.txt |
— | — | @@ -8,6 +8,7 @@ |
9 | 9 | # (default) generate HTML output |
10 | 10 | # pst apply pre-save transform |
11 | 11 | # msg apply message transform |
| 12 | +# subpage enable subpages (disabled by default) |
12 | 13 | # |
13 | 14 | # Tests can be disabled with the '!!disabled' flag. |
14 | 15 | # |
— | — | @@ -15,6 +16,14 @@ |
16 | 17 | # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle |
17 | 18 | # where '/' denotes a newline. |
18 | 19 | |
| 20 | +# This is the standard article assumed to exist. |
| 21 | +!! article |
| 22 | +Main Page |
| 23 | +!! text |
| 24 | +blah blah |
| 25 | +!! endarticle |
| 26 | + |
| 27 | + |
19 | 28 | ### |
20 | 29 | ### Basic tests |
21 | 30 | ### |
— | — | @@ -143,7 +152,7 @@ |
144 | 153 | ### comment test cases |
145 | 154 | ### |
146 | 155 | !! test |
147 | | -comment test 1 |
| 156 | +Comment test 1 |
148 | 157 | !! input |
149 | 158 | <!-- comment 1 --> asdf |
150 | 159 | <!-- comment 2 --> |
— | — | @@ -154,7 +163,7 @@ |
155 | 164 | !! end |
156 | 165 | |
157 | 166 | !! test |
158 | | -comment test 2 |
| 167 | +Comment test 2 |
159 | 168 | !! input |
160 | 169 | asdf |
161 | 170 | <!-- comment 1 --> |
— | — | @@ -166,7 +175,7 @@ |
167 | 176 | !! end |
168 | 177 | |
169 | 178 | !! test |
170 | | -comment test 3 |
| 179 | +Comment test 3 |
171 | 180 | !! input |
172 | 181 | asdf |
173 | 182 | <!-- comment 1 --> |
— | — | @@ -179,7 +188,7 @@ |
180 | 189 | !! end |
181 | 190 | |
182 | 191 | !! test |
183 | | -comment test 4 |
| 192 | +Comment test 4 |
184 | 193 | !! input |
185 | 194 | asdf<!-- comment 1 -->jkl |
186 | 195 | !! result |
— | — | @@ -187,7 +196,65 @@ |
188 | 197 | </p> |
189 | 198 | !! end |
190 | 199 | |
| 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 | + |
191 | 215 | ### |
| 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 </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 | +### |
192 | 259 | ### External links |
193 | 260 | ### |
194 | 261 | !! test |
— | — | @@ -529,12 +596,6 @@ |
530 | 597 | ### |
531 | 598 | ### Internal links |
532 | 599 | ### |
533 | | -!! article |
534 | | -Main Page |
535 | | -!! text |
536 | | -blah blah |
537 | | -!! endarticle |
538 | | - |
539 | 600 | !! test |
540 | 601 | Plain link, capitalized |
541 | 602 | !! input |
— | — | @@ -908,6 +969,21 @@ |
909 | 970 | !! end |
910 | 971 | |
911 | 972 | |
| 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 | + |
912 | 988 | !! article |
913 | 989 | Template:Linktest2 |
914 | 990 | !! text |
— | — | @@ -923,6 +999,7 @@ |
924 | 1000 | </p> |
925 | 1001 | !! end |
926 | 1002 | |
| 1003 | + |
927 | 1004 | !! article |
928 | 1005 | Template:loop1 |
929 | 1006 | !! text |
— | — | @@ -978,6 +1055,7 @@ |
979 | 1056 | {{thistemplatedoesnotexist}} |
980 | 1057 | !! end |
981 | 1058 | |
| 1059 | + |
982 | 1060 | !! test |
983 | 1061 | pre-save transform: subst magic variables |
984 | 1062 | !! options |
— | — | @@ -988,6 +1066,17 @@ |
989 | 1067 | MediaWiki |
990 | 1068 | !! end |
991 | 1069 | |
| 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 | + |
992 | 1081 | ### |
993 | 1082 | ### Message transform tests |
994 | 1083 | ### |
— | — | @@ -1011,11 +1100,99 @@ |
1012 | 1101 | ''test'' |
1013 | 1102 | !! end |
1014 | 1103 | |
| 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&action=edit" class="new" title="Subpage">subpage</a> |
| 1190 | +</p> |
| 1191 | +!! end |
| 1192 | + |
1015 | 1193 | TODO: |
1016 | | -more templates |
1017 | | -tables |
1018 | | -images |
1019 | | -subpages |
| 1194 | +more images |
| 1195 | +more tables |
| 1196 | +math |
1020 | 1197 | character entities |
1021 | 1198 | and much more |
1022 | 1199 | |
Index: trunk/phase3/maintenance/parserTests.php |
— | — | @@ -177,10 +177,18 @@ |
178 | 178 | function runTest( $desc, $input, $result, $opts ) { |
179 | 179 | print "Running test $desc... "; |
180 | 180 | |
181 | | - $this->setupGlobals(); |
| 181 | + $this->setupGlobals($opts); |
182 | 182 | |
183 | 183 | $user =& new User(); |
184 | 184 | $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 | + |
185 | 193 | $parser =& new Parser(); |
186 | 194 | $title =& Title::makeTitle( NS_MAIN, 'Parser_test' ); |
187 | 195 | |
— | — | @@ -224,7 +232,7 @@ |
225 | 233 | * |
226 | 234 | * @access private |
227 | 235 | */ |
228 | | - function setupGlobals() { |
| 236 | + function setupGlobals($opts = '') { |
229 | 237 | $settings = array( |
230 | 238 | 'wgServer' => 'http://localhost', |
231 | 239 | 'wgScript' => '/index.php', |
— | — | @@ -237,6 +245,7 @@ |
238 | 246 | |
239 | 247 | 'wgLoadBalancer' => LoadBalancer::newFromParams( $GLOBALS['wgDBservers'] ), |
240 | 248 | 'wgLang' => new LanguageUtf8(), |
| 249 | + 'wgNamespacesWithSubpages' => array( 0 => preg_match('/subpage/i', $opts)), |
241 | 250 | ); |
242 | 251 | $this->savedGlobals = array(); |
243 | 252 | foreach( $settings as $var => $val ) { |