!! Version 2 # Force the test runner to ensure the extension is loaded !! functionhooks time !! endfunctionhooks # fixme: #time seems to be accepting input as local time, which strikes me as wrong !! article ParserFunctions page !! text A sample page so we can test ifexist. This used to be a Main Page, but that caused duplicate article warnings when running the normal tests at the same time. !! endarticle !! article File:Dionysos-Brunnen am Kölner Dom.jpg !! text blah blah !! endarticle !! article File:Redirect_to_Foobar.jpg !! text #REDIRECT[[File:Foobar.jpg]] !! endarticle !! article File:Redirect_to_nowhere.jpg !! text #REDIRECT[[File:Missing target file.jpg]] !! endarticle !! test Input times are UTC, not local time !! wikitext {{#time:c|15 January 2001}} !! html

2001-01-15T00:00:00+00:00

!! end !! test Time test in traditional range... !! wikitext {{#time:Y|15 January 2001}} !! html

2001

!! end !! test Time test prior to 1970 Unix creation myth !! wikitext {{#time:Y|5 April 1967}} !! html

1967

!! end !! test Time test after the 2038 32-bit Apocalype !! wikitext {{#time:Y|28 July 2061}} !! html

2061

!! end !! test Explicitly specified timezone: UTC !! wikitext {{#time:Y-m-d H:i| 2011-11-12 23:00 UTC }} !! html

2011-11-12 23:00

!! end !! test Explicitly specified timezone: Europe/Paris (UTC+1) !! wikitext {{#time:Y-m-d H:i| 2011-11-12 23:00 Europe/Paris }} !! html

2011-11-12 22:00

!! end !! test Explicitly specified timezone: America/New_York (UTC-5) !! wikitext {{#time:Y-m-d H:i| 2011-11-12 23:00 America/New_York }} !! html

2011-11-13 04:00

!! end !! test Explicitely specified output language (Dutch) !! wikitext {{#time:d F Y|1988-02-28|nl}} !! html

28 februari 1988

!! end !! test #titleparts !! wikitext {{#titleparts:A/b/c/d}} {{#titleparts:A/b/c/d|1}} {{#titleparts:A/b/c/d|2}} {{#titleparts:A/b/c/d|-3}} {{#titleparts:A/b/c/d||1}} {{#titleparts:A/b/c/d||2}} {{#titleparts:A/b/c/d||-2}} {{#titleparts:A/b/c/d|1|1}} {{#titleparts:A/b/c/d|1|2}} {{#titleparts:A/b/c/d|1|-2}} !! html

A/b/c/d A A/b A A/b/c/d b/c/d c/d A b c

!! end !! test #titleparts stops splitting after 25 parts !! wikitext {{#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}} {{#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}} {{#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}} {{#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}} !! html

A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/!/!/! A/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x !/!/!

!! end !! test Zero parameters in #if and such !! wikitext [{{#ifexpr:}},{{#if:}},{{#ifeq:}},{{#switch:}},{{#ifexist:}}] !! html

[,,,,]

!! end !! test Empty condition in #if and such !! wikitext Empty ifexpr is {{#ifexpr:|true|false}} Empty if is {{#if:|true|false}} Empty ifeq is {{#ifeq:||equal|not equal}} Empty switch is {{#switch:|=empty|#default=something else}} Empty ifexist is {{#ifexist:|true|false}} !! html

Empty ifexpr is false Empty if is false Empty ifeq is equal Empty switch is empty Empty ifexist is false

!! end !! test Missing or all-empty outputs !! wikitext [{{#ifexpr: 1}},{{#ifexpr: 1|}},{{#ifexpr: 1||}}] [{{#if: 1}},{{#if: 1|}},{{#if: 1||}}] [{{#ifeq: 1|1}},{{#ifeq: 1|1|}},{{#ifeq: 1|1||}}] [{{#switch: 1}},{{#switch: 1|}}] [{{#ifexist: ParserFunctions page}},{{#ifexist: ParserFunctions page|}},{{#ifexist: ParserFunctions page||}}] !! html

[,,] [,,] [,,] [,] [,,]

!! end !! test Preserve tags in #switch default value !! wikitext {{#switch:a|b|
c
}} !! html
c
!! end !! test Bug 19093: Default values don't fall through in switch !! wikitext <{{#switch: foo | bar | #default = DEF }}> <{{#switch: foo | #default | bar = DEF }}> !! html

<DEF> <DEF>

!! end !! test {{#ifexist}} !! wikitext {{#ifexist:Media:Foobar.jpg|Found|Not found}} {{#ifexist:ParserFunctions page|Found|Not found}} {{#ifexist:Missing|Found|Not found}} !! html

Found Found Not found

!! end !! test {{#ifexist:}} media redirect (bug 32031) !! wikitext {{#ifexist:Media:Redirect_to_Foobar.jpg|Found|Not found}} {{#ifexist:Media:Redirect_to_nowhere.jpg|Found|Not found}} {{#ifexist:Media:Missing file.jpg|Found|Not found}} {{#ifexist:Media:Dionysos-Brunnen am Kölner Dom.jpg|Found|Not found}} !! html

Found Not found Not found Not found

!!end !! test #if !! wikitext {{#if: | yes | no}} {{#if: string | yes | no}} {{#if: | yes | no}} {{#if: | yes | no}} {{#if: 1==2 | yes | no}} {{#if: foo | yes }} {{#if: | yes }}(empty) {{#if: foo | | no}}(empty) {{#if: {{{1}}} | yes | no}} {{#if: {{{1|}}} | yes | no}} !! html

no yes no no yes yes (empty) (empty) yes no

!! end !! test #ifeq !! wikitext {{#ifeq: 01 | 1 | yes | no}} {{#ifeq: 0 | -0 | yes | no}} {{#ifeq: foo | bar | yes | no}} {{#ifeq: foo | Foo | yes | no}} {{#ifeq: "01" | "1" | yes | no}} !! html

yes yes no no no

!! end !! test #ifeq entities !! wikitext {{#ifeq: {{PAGENAME:*foo&bar}} | *foo&bar | yes | no}} {{#ifeq: a'b | a'b | yes | no}} {{#ifeq: a'b | a&#39;b | yes | no}} {{#ifeq: foo | Foo | *yes | *no}} !! html

yes yes no

!! end !! test #iferror !! wikitext {{#iferror: {{#expr: 1 + 2 }} | error | correct }} {{#iferror: {{#expr: 1 + X }} | error | correct }} {{#iferror: {{#expr: 1 + 2 }} | error }} {{#iferror: {{#expr: 1 + X }} | error }} {{#iferror: {{#expr: 1 + 2 }} }} {{#iferror: {{#expr: 1 + X }} }}empty !! html

correct error 3 error 3 empty

!! end !! test #ifexpr !! wikitext {{#ifexpr: | yes | no}} {{#ifexpr: 1 > 0 | yes }} {{#ifexpr: 1 < 0 | yes }}empty {{#ifexpr: 1 > 0 | | no}}empty {{#ifexpr: 1 < 0 | | no}} {{#ifexpr: 1 > 0 }}empty !! html

no yes empty empty no empty

!! end !! test Bug 22866: #ifexpr should evaluate "-0" as false !! wikitext {{#ifexpr: (-1)*0 | true | false }} !! html

false

!! end !! test Templates: Parser functions don't strip whitespace from positional parameters !! wikitext {{#if: {{foo}} | no-pre-then | no-pre-else }} !! html

no-pre-then

!! end !! test #switch !! wikitext {{#switch:foo&bar|foo&bar=yes|no}} {{#switch:foo&bar|fred=1|foo&bar|g=yes|no}} {{#switch:foo&bar|fred=1|foo&'bar|g=yes|no}} {{#switch:foo|bar|baz=no|*default}} {{#switch:none|foo=1|bar=2|#default=no match|baz=3}} {{#switch:none|foo=1|bar=2|#default=ignored|baz=3|Second default}} {{#switch:|a&#39;b}} !! html

yes yes no

no match Second default a&#39;b

!!end !! test #switch #default should match next and not last named parameter !! wikitext <{{#switch: foo | #default | bar = DEF }}> <{{#switch: foo | #default | bar = DEF | baz = GHI }}> !! html

<DEF> <DEF>

!! end !! test #switch should not match #default as a prefix !! wikitext <{{#switch: foo | #defaultWTF? = This is crazy }}> <{{#switch: foo | #defaultWTF? | bar = This is crazy }}> !! html

<> <>

!! end !! test #switch Test php truthy !! wikitext {{#switch: 01 | 1 = yes | no}} {{#switch: 0 | -0 = yes | no}} {{#switch: foo | bar = yes | no}} {{#switch: foo | Foo = yes | no}} {{#switch: "01" | "1" = yes | no}} {{#switch: 1 | 02 | 01 = yes | no}} {{#switch: 1 | "01" | "1" = yes | no}} !! html

yes yes no no no yes no

!! end