| 1 |
!! Version 2 |
| 2 |
# Force the test runner to ensure the extension is loaded |
| 3 |
!! functionhooks |
| 4 |
time |
| 5 |
!! endfunctionhooks |
| 6 |
|
| 7 |
# fixme: #time seems to be accepting input as local time, which strikes me as wrong |
| 8 |
|
| 9 |
!! article |
| 10 |
ParserFunctions page |
| 11 |
!! text |
| 12 |
A sample page so we can test ifexist. |
| 13 |
|
| 14 |
This used to be a Main Page, but that caused duplicate article |
| 15 |
warnings when running the normal tests at the same time. |
| 16 |
!! endarticle |
| 17 |
|
| 18 |
!! article |
| 19 |
File:Dionysos-Brunnen am Kölner Dom.jpg |
| 20 |
!! text |
| 21 |
blah blah |
| 22 |
!! endarticle |
| 23 |
|
| 24 |
!! article |
| 25 |
File:Redirect_to_Foobar.jpg |
| 26 |
!! text |
| 27 |
#REDIRECT[[File:Foobar.jpg]] |
| 28 |
!! endarticle |
| 29 |
|
| 30 |
!! article |
| 31 |
File:Redirect_to_nowhere.jpg |
| 32 |
!! text |
| 33 |
#REDIRECT[[File:Missing target file.jpg]] |
| 34 |
!! endarticle |
| 35 |
|
| 36 |
!! test |
| 37 |
Input times are UTC, not local time |
| 38 |
!! wikitext |
| 39 |
{{#time:c|15 January 2001}} |
| 40 |
!! html |
| 41 |
<p>2001-01-15T00:00:00+00:00 |
| 42 |
</p> |
| 43 |
!! end |
| 44 |
|
| 45 |
!! test |
| 46 |
Time test in traditional range... |
| 47 |
!! wikitext |
| 48 |
{{#time:Y|15 January 2001}} |
| 49 |
!! html |
| 50 |
<p>2001 |
| 51 |
</p> |
| 52 |
!! end |
| 53 |
|
| 54 |
!! test |
| 55 |
Time test prior to 1970 Unix creation myth |
| 56 |
!! wikitext |
| 57 |
{{#time:Y|5 April 1967}} |
| 58 |
!! html |
| 59 |
<p>1967 |
| 60 |
</p> |
| 61 |
!! end |
| 62 |
|
| 63 |
!! test |
| 64 |
Time test after the 2038 32-bit Apocalype |
| 65 |
!! wikitext |
| 66 |
{{#time:Y|28 July 2061}} |
| 67 |
!! html |
| 68 |
<p>2061 |
| 69 |
</p> |
| 70 |
!! end |
| 71 |
|
| 72 |
!! test |
| 73 |
Explicitly specified timezone: UTC |
| 74 |
!! wikitext |
| 75 |
{{#time:Y-m-d H:i| 2011-11-12 23:00 UTC }} |
| 76 |
!! html |
| 77 |
<p>2011-11-12 23:00 |
| 78 |
</p> |
| 79 |
!! end |
| 80 |
|
| 81 |
!! test |
| 82 |
Explicitly specified timezone: Europe/Paris (UTC+1) |
| 83 |
!! wikitext |
| 84 |
{{#time:Y-m-d H:i| 2011-11-12 23:00 Europe/Paris }} |
| 85 |
!! html |
| 86 |
<p>2011-11-12 22:00 |
| 87 |
</p> |
| 88 |
!! end |
| 89 |
|
| 90 |
!! test |
| 91 |
Explicitly specified timezone: America/New_York (UTC-5) |
| 92 |
!! wikitext |
| 93 |
{{#time:Y-m-d H:i| 2011-11-12 23:00 America/New_York }} |
| 94 |
!! html |
| 95 |
<p>2011-11-13 04:00 |
| 96 |
</p> |
| 97 |
!! end |
| 98 |
|
| 99 |
!! test |
| 100 |
Explicitly specified output language (Dutch) |
| 101 |
!! wikitext |
| 102 |
{{#time:d F Y|1988-02-28|nl}} |
| 103 |
!! html |
| 104 |
<p>28 februari 1988 |
| 105 |
</p> |
| 106 |
!! end |
| 107 |
|
| 108 |
!! test |
| 109 |
#timel: UTC |
| 110 |
!! wikitext |
| 111 |
{{#timel: Y-m-d H:i | 15 January 2001}} |
| 112 |
!! html |
| 113 |
<p>2001-01-15 00:00 |
| 114 |
</p> |
| 115 |
!! end |
| 116 |
|
| 117 |
!! test |
| 118 |
#timel: Melbourne |
| 119 |
!! options |
| 120 |
wgLocaltimezone=Australia/Melbourne |
| 121 |
!! wikitext |
| 122 |
{{#timel: Y-m-d H:i | 16 January 2001}} |
| 123 |
!! html |
| 124 |
<p>2001-01-16 11:00 |
| 125 |
</p> |
| 126 |
!! end |
| 127 |
|
| 128 |
!! test |
| 129 |
#timef: one parameter |
| 130 |
!! wikitext |
| 131 |
{{#timef:15 January 2001}} |
| 132 |
!! html |
| 133 |
<p>00:00, 15 January 2001 |
| 134 |
</p> |
| 135 |
!! end |
| 136 |
|
| 137 |
!! test |
| 138 |
#timef: date only |
| 139 |
!! wikitext |
| 140 |
{{#timef:15 January 2001|date}} |
| 141 |
!! html |
| 142 |
<p>15 January 2001 |
| 143 |
</p> |
| 144 |
!! end |
| 145 |
|
| 146 |
!! test |
| 147 |
#timef: time only |
| 148 |
!! wikitext |
| 149 |
{{#timef:15 January 2001|time}} |
| 150 |
!! html |
| 151 |
<p>00:00 |
| 152 |
</p> |
| 153 |
!! end |
| 154 |
|
| 155 |
!! test |
| 156 |
#timef: "pretty" format |
| 157 |
!! wikitext |
| 158 |
{{#timef:15 January 2001|pretty}} |
| 159 |
!! html |
| 160 |
<p>15 January |
| 161 |
</p> |
| 162 |
!! end |
| 163 |
|
| 164 |
!! test |
| 165 |
#timef: Japanese target language |
| 166 |
!! options |
| 167 |
language=ja |
| 168 |
!! wikitext |
| 169 |
{{#timef:15 January 2001}} |
| 170 |
!! html |
| 171 |
<p>2001年1月15日 (月) 00:00 |
| 172 |
</p> |
| 173 |
!! end |
| 174 |
|
| 175 |
!! test |
| 176 |
#timef: ja parameter |
| 177 |
!! wikitext |
| 178 |
{{#timef:15 January 2001|both|ja}} |
| 179 |
!! html |
| 180 |
<p>2001年1月15日 (月) 00:00 |
| 181 |
</p> |
| 182 |
!! end |
| 183 |
|
| 184 |
!! test |
| 185 |
#timefl: one parameter |
| 186 |
!! options |
| 187 |
wgLocaltimezone=Australia/Melbourne |
| 188 |
!! wikitext |
| 189 |
{{#timefl:17 January 2001}} |
| 190 |
!! html |
| 191 |
<p>11:00, 17 January 2001 |
| 192 |
</p> |
| 193 |
!! end |
| 194 |
|
| 195 |
!! test |
| 196 |
#titleparts |
| 197 |
!! wikitext |
| 198 |
{{#titleparts:A/b/c/d}} |
| 199 |
{{#titleparts:A/b/c/d|1}} |
| 200 |
{{#titleparts:A/b/c/d|2}} |
| 201 |
{{#titleparts:A/b/c/d|-3}} |
| 202 |
{{#titleparts:A/b/c/d||1}} |
| 203 |
{{#titleparts:A/b/c/d||2}} |
| 204 |
{{#titleparts:A/b/c/d||-2}} |
| 205 |
{{#titleparts:A/b/c/d|1|1}} |
| 206 |
{{#titleparts:A/b/c/d|1|2}} |
| 207 |
{{#titleparts:A/b/c/d|1|-2}} |
| 208 |
!! html |
| 209 |
<p>A/b/c/d |
| 210 |
A |
| 211 |
A/b |
| 212 |
A |
| 213 |
A/b/c/d |
| 214 |
b/c/d |
| 215 |
c/d |
| 216 |
A |
| 217 |
b |
| 218 |
c |
| 219 |
</p> |
| 220 |
!! end |
| 221 |
|
| 222 |
!! test |
| 223 |
#titleparts stops splitting after 25 parts |
| 224 |
!! wikitext |
| 225 |
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!|24}} |
| 226 |
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!|25}} |
| 227 |
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!|-1}} |
| 228 |
{{#titleparts:A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/!||-1}} |
| 229 |
!! html |
| 230 |
<p>A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x |
| 231 |
A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/! |
| 232 |
A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x |
| 233 |
!/!/! |
| 234 |
</p> |
| 235 |
!! end |
| 236 |
|
| 237 |
!! test |
| 238 |
Zero parameters in #if and such |
| 239 |
!! wikitext |
| 240 |
[{{#ifexpr:}},{{#if:}},{{#ifeq:}},{{#switch:}},{{#ifexist:}}] |
| 241 |
!! html |
| 242 |
<p>[,,,,] |
| 243 |
</p> |
| 244 |
!! end |
| 245 |
|
| 246 |
!! test |
| 247 |
Empty condition in #if and such |
| 248 |
!! wikitext |
| 249 |
Empty ifexpr is {{#ifexpr:|true|false}} |
| 250 |
Empty if is {{#if:|true|false}} |
| 251 |
Empty ifeq is {{#ifeq:||equal|not equal}} |
| 252 |
Empty switch is {{#switch:|=empty|#default=something else}} |
| 253 |
Empty ifexist is {{#ifexist:|true|false}} |
| 254 |
!! html |
| 255 |
<p>Empty ifexpr is false |
| 256 |
Empty if is false |
| 257 |
Empty ifeq is equal |
| 258 |
Empty switch is empty |
| 259 |
Empty ifexist is false |
| 260 |
</p> |
| 261 |
!! end |
| 262 |
|
| 263 |
!! test |
| 264 |
Missing or all-empty outputs |
| 265 |
!! wikitext |
| 266 |
[{{#ifexpr: 1}},{{#ifexpr: 1|}},{{#ifexpr: 1||}}] |
| 267 |
[{{#if: 1}},{{#if: 1|}},{{#if: 1||}}] |
| 268 |
[{{#ifeq: 1|1}},{{#ifeq: 1|1|}},{{#ifeq: 1|1||}}] |
| 269 |
[{{#switch: 1}},{{#switch: 1|}}] |
| 270 |
[{{#ifexist: ParserFunctions page}},{{#ifexist: ParserFunctions page|}},{{#ifexist: ParserFunctions page||}}] |
| 271 |
!! html |
| 272 |
<p>[,,] |
| 273 |
[,,] |
| 274 |
[,,] |
| 275 |
[,] |
| 276 |
[,,] |
| 277 |
</p> |
| 278 |
!! end |
| 279 |
|
| 280 |
!! test |
| 281 |
Preserve tags in #switch default value |
| 282 |
!! wikitext |
| 283 |
{{#switch:a|b|<div>c</div>}} |
| 284 |
!! html |
| 285 |
<div>c</div> |
| 286 |
!! end |
| 287 |
|
| 288 |
!! test |
| 289 |
Bug 19093: Default values don't fall through in switch |
| 290 |
!! wikitext |
| 291 |
<{{#switch: foo | bar | #default = DEF }}> |
| 292 |
<{{#switch: foo | #default | bar = DEF }}> |
| 293 |
!! html |
| 294 |
<p><DEF> |
| 295 |
<DEF> |
| 296 |
</p> |
| 297 |
!! end |
| 298 |
|
| 299 |
!! test |
| 300 |
{{#ifexist}} |
| 301 |
!! wikitext |
| 302 |
{{#ifexist:Media:Foobar.jpg|Found|Not found}} |
| 303 |
{{#ifexist:ParserFunctions page|Found|Not found}} |
| 304 |
{{#ifexist:Missing|Found|Not found}} |
| 305 |
!! html |
| 306 |
<p>Found |
| 307 |
Found |
| 308 |
Not found |
| 309 |
</p> |
| 310 |
!! end |
| 311 |
|
| 312 |
!! test |
| 313 |
{{#ifexist:}} media redirect (bug 32031) |
| 314 |
!! wikitext |
| 315 |
{{#ifexist:Media:Redirect_to_Foobar.jpg|Found|Not found}} |
| 316 |
{{#ifexist:Media:Redirect_to_nowhere.jpg|Found|Not found}} |
| 317 |
{{#ifexist:Media:Missing file.jpg|Found|Not found}} |
| 318 |
{{#ifexist:Media:Dionysos-Brunnen am Kölner Dom.jpg|Found|Not found}} |
| 319 |
!! html |
| 320 |
<p>Found |
| 321 |
Not found |
| 322 |
Not found |
| 323 |
Not found |
| 324 |
</p> |
| 325 |
!!end |
| 326 |
|
| 327 |
!! test |
| 328 |
#if |
| 329 |
!! wikitext |
| 330 |
{{#if: | yes | no}} |
| 331 |
{{#if: string | yes | no}} |
| 332 |
{{#if: | yes | no}} |
| 333 |
{{#if: |
| 334 |
|
| 335 |
|
| 336 |
| yes | no}} |
| 337 |
{{#if: 1==2 | yes | no}} |
| 338 |
{{#if: foo | yes }} |
| 339 |
{{#if: | yes }}(empty) |
| 340 |
{{#if: foo | | no}}(empty) |
| 341 |
{{#if: {{{1}}} | yes | no}} |
| 342 |
{{#if: {{{1|}}} | yes | no}} |
| 343 |
!! html |
| 344 |
<p>no |
| 345 |
yes |
| 346 |
no |
| 347 |
no |
| 348 |
yes |
| 349 |
yes |
| 350 |
(empty) |
| 351 |
(empty) |
| 352 |
yes |
| 353 |
no |
| 354 |
</p> |
| 355 |
!! end |
| 356 |
|
| 357 |
!! test |
| 358 |
#ifeq |
| 359 |
!! wikitext |
| 360 |
{{#ifeq: 01 | 1 | yes | no}} |
| 361 |
{{#ifeq: 0 | -0 | yes | no}} |
| 362 |
{{#ifeq: foo | bar | yes | no}} |
| 363 |
{{#ifeq: foo | Foo | yes | no}} |
| 364 |
{{#ifeq: "01" | "1" | yes | no}} |
| 365 |
!! html |
| 366 |
<p>yes |
| 367 |
yes |
| 368 |
no |
| 369 |
no |
| 370 |
no |
| 371 |
</p> |
| 372 |
!! end |
| 373 |
|
| 374 |
!! test |
| 375 |
#ifeq entities |
| 376 |
!! wikitext |
| 377 |
{{#ifeq: {{PAGENAME:*foo&bar}} | *foo&bar | yes | no}} |
| 378 |
{{#ifeq: a'b | a'b | yes | no}} |
| 379 |
{{#ifeq: a'b | a&#39;b | yes | no}} |
| 380 |
{{#ifeq: foo | Foo | *yes | *no}} |
| 381 |
!! html |
| 382 |
<p>yes |
| 383 |
yes |
| 384 |
no |
| 385 |
</p> |
| 386 |
<ul><li>no</li></ul> |
| 387 |
!! end |
| 388 |
|
| 389 |
|
| 390 |
!! test |
| 391 |
#iferror |
| 392 |
!! wikitext |
| 393 |
{{#iferror: {{#expr: 1 + 2 }} | error | correct }} |
| 394 |
{{#iferror: {{#expr: 1 + X }} | error | correct }} |
| 395 |
{{#iferror: {{#expr: 1 + 2 }} | error }} |
| 396 |
{{#iferror: {{#expr: 1 + X }} | error }} |
| 397 |
{{#iferror: {{#expr: 1 + 2 }} }} |
| 398 |
{{#iferror: {{#expr: 1 + X }} }}empty |
| 399 |
!! html |
| 400 |
<p>correct |
| 401 |
error |
| 402 |
3 |
| 403 |
error |
| 404 |
3 |
| 405 |
empty |
| 406 |
</p> |
| 407 |
!! end |
| 408 |
|
| 409 |
|
| 410 |
!! test |
| 411 |
#ifexpr |
| 412 |
!! wikitext |
| 413 |
{{#ifexpr: | yes | no}} |
| 414 |
{{#ifexpr: 1 > 0 | yes }} |
| 415 |
{{#ifexpr: 1 < 0 | yes }}empty |
| 416 |
{{#ifexpr: 1 > 0 | | no}}empty |
| 417 |
{{#ifexpr: 1 < 0 | | no}} |
| 418 |
{{#ifexpr: 1 > 0 }}empty |
| 419 |
!! html |
| 420 |
<p>no |
| 421 |
yes |
| 422 |
empty |
| 423 |
empty |
| 424 |
no |
| 425 |
empty |
| 426 |
</p> |
| 427 |
!! end |
| 428 |
|
| 429 |
!! test |
| 430 |
Bug 22866: #ifexpr should evaluate "-0" as false |
| 431 |
!! wikitext |
| 432 |
{{#ifexpr: (-1)*0 | true | false }} |
| 433 |
!! html |
| 434 |
<p>false |
| 435 |
</p> |
| 436 |
!! end |
| 437 |
|
| 438 |
!! test |
| 439 |
Templates: Parser functions don't strip whitespace from positional parameters |
| 440 |
!! wikitext |
| 441 |
{{#if: {{foo}} |
| 442 |
| no-pre-then |
| 443 |
| no-pre-else |
| 444 |
}} |
| 445 |
!! html |
| 446 |
<p>no-pre-then |
| 447 |
</p> |
| 448 |
!! end |
| 449 |
|
| 450 |
!! test |
| 451 |
#switch |
| 452 |
!! wikitext |
| 453 |
{{#switch:foo&bar|foo&bar=yes|no}} |
| 454 |
{{#switch:foo&bar|fred=1|foo&bar|g=yes|no}} |
| 455 |
{{#switch:foo&bar|fred=1|foo&'bar|g=yes|no}} |
| 456 |
{{#switch:foo|bar|baz=no|*default}} |
| 457 |
{{#switch:none|foo=1|bar=2|#default=no match|baz=3}} |
| 458 |
{{#switch:none|foo=1|bar=2|#default=ignored|baz=3|Second default}} |
| 459 |
{{#switch:|a&#39;b}} |
| 460 |
!! html |
| 461 |
<p>yes |
| 462 |
yes |
| 463 |
no |
| 464 |
</p> |
| 465 |
<ul><li>default</li></ul> |
| 466 |
<p>no match |
| 467 |
Second default |
| 468 |
a&#39;b |
| 469 |
</p> |
| 470 |
!!end |
| 471 |
|
| 472 |
!! test |
| 473 |
#switch #default should match next and not last named parameter |
| 474 |
!! wikitext |
| 475 |
<{{#switch: foo | #default | bar = DEF }}> |
| 476 |
<{{#switch: foo | #default | bar = DEF | baz = GHI }}> |
| 477 |
!! html |
| 478 |
<p><DEF> |
| 479 |
<DEF> |
| 480 |
</p> |
| 481 |
!! end |
| 482 |
|
| 483 |
!! test |
| 484 |
#switch should not match #default as a prefix |
| 485 |
!! wikitext |
| 486 |
<{{#switch: foo | #defaultWTF? = This is crazy }}> |
| 487 |
<{{#switch: foo | #defaultWTF? | bar = This is crazy }}> |
| 488 |
!! html |
| 489 |
<p><> |
| 490 |
<> |
| 491 |
</p> |
| 492 |
!! end |
| 493 |
|
| 494 |
!! test |
| 495 |
#switch Test php truthy |
| 496 |
!! wikitext |
| 497 |
{{#switch: 01 | 1 = yes | no}} |
| 498 |
{{#switch: 0 | -0 = yes | no}} |
| 499 |
{{#switch: foo | bar = yes | no}} |
| 500 |
{{#switch: foo | Foo = yes | no}} |
| 501 |
{{#switch: "01" | "1" = yes | no}} |
| 502 |
{{#switch: 1 | 02 | 01 = yes | no}} |
| 503 |
{{#switch: 1 | "01" | "1" = yes | no}} |
| 504 |
!! html |
| 505 |
<p>yes |
| 506 |
yes |
| 507 |
no |
| 508 |
no |
| 509 |
no |
| 510 |
yes |
| 511 |
no |
| 512 |
</p> |
| 513 |
!! end |