[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 # Force the test runner to ensure the extension is loaded 2 # fixme... this doesn't seem to work :D 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 !! input 39 {{#time:c|15 January 2001}} 40 !!result 41 <p>2001-01-15T00:00:00+00:00 42 </p> 43 !! end 44 45 !! test 46 Time test in traditional range... 47 !! input 48 {{#time:Y|15 January 2001}} 49 !! result 50 <p>2001 51 </p> 52 !! end 53 54 !! test 55 Time test prior to 1970 Unix creation myth 56 !! input 57 {{#time:Y|5 April 1967}} 58 !! result 59 <p>1967 60 </p> 61 !! end 62 63 !! test 64 Time test after the 2038 32-bit Apocalype 65 !! input 66 {{#time:Y|28 July 2061}} 67 !! result 68 <p>2061 69 </p> 70 !! end 71 72 !! test 73 Explicitly specified timezone: UTC 74 !! input 75 {{#time:Y-m-d H:i| 2011-11-12 23:00 UTC }} 76 !! result 77 <p>2011-11-12 23:00 78 </p> 79 !! end 80 81 !! test 82 Explicitly specified timezone: Europe/Paris (UTC+1) 83 !! input 84 {{#time:Y-m-d H:i| 2011-11-12 23:00 Europe/Paris }} 85 !! result 86 <p>2011-11-12 22:00 87 </p> 88 !! end 89 90 !! test 91 Explicitly specified timezone: America/New_York (UTC-5) 92 !! input 93 {{#time:Y-m-d H:i| 2011-11-12 23:00 America/New_York }} 94 !! result 95 <p>2011-11-13 04:00 96 </p> 97 !! end 98 99 !! test 100 Explicitely specified output language (Dutch) 101 !! input 102 {{#time:d F Y|1988-02-28|nl}} 103 !! result 104 <p>28 februari 1988 105 </p> 106 !! end 107 108 !! test 109 Preserve tags in #switch default value 110 !! input 111 {{#switch:a|b|<div>c</div>}} 112 !! result 113 <div>c</div> 114 115 !! end 116 117 !! test 118 Bug 19093: Default values don't fall through in switch 119 !! input 120 <{{#switch: foo | bar | #default = DEF }}> 121 <{{#switch: foo | #default | bar = DEF }}> 122 !! result 123 <p><DEF> 124 <DEF> 125 </p> 126 !! end 127 128 !! test 129 {{#ifexist}} 130 !! input 131 {{#ifexist:Media:Foobar.jpg|Found|Not found}} 132 {{#ifexist:ParserFunctions page|Found|Not found}} 133 {{#ifexist:Missing|Found|Not found}} 134 !! result 135 <p>Found 136 Found 137 Not found 138 </p> 139 !! end 140 141 !! test 142 {{#ifexist:}} media redirect (bug 32031) 143 !! input 144 {{#ifexist:Media:Redirect_to_Foobar.jpg|Found|Not found}} 145 {{#ifexist:Media:Redirect_to_nowhere.jpg|Found|Not found}} 146 {{#ifexist:Media:Missing file.jpg|Found|Not found}} 147 {{#ifexist:Media:Dionysos-Brunnen am Kölner Dom.jpg|Found|Not found}} 148 !!result 149 <p>Found 150 Not found 151 Not found 152 Not found 153 </p> 154 !!end 155 156 !! test 157 #if 158 !! input 159 {{#if: | yes | no}} 160 {{#if: string | yes | no}} 161 {{#if: | yes | no}} 162 {{#if: 163 164 165 | yes | no}} 166 {{#if: 1==2 | yes | no}} 167 {{#if: foo | yes }} 168 {{#if: | yes }}(empty) 169 {{#if: foo | | no}}(empty) 170 {{#if: {{{1}}} | yes | no}} 171 {{#if: {{{1|}}} | yes | no}} 172 !! result 173 <p>no 174 yes 175 no 176 no 177 yes 178 yes 179 (empty) 180 (empty) 181 yes 182 no 183 </p> 184 !! end 185 186 !! test 187 #ifeq 188 !!input 189 {{#ifeq: 01 | 1 | yes | no}} 190 {{#ifeq: 0 | -0 | yes | no}} 191 {{#ifeq: foo | bar | yes | no}} 192 {{#ifeq: foo | Foo | yes | no}} 193 {{#ifeq: "01" | "1" | yes | no}} 194 !! result 195 <p>yes 196 yes 197 no 198 no 199 no 200 </p> 201 !! end 202 203 !! test 204 #ifeq entities 205 !!input 206 {{#ifeq: {{PAGENAME:*foo&bar}} | *foo&bar | yes | no}} 207 {{#ifeq: a'b | a'b | yes | no}} 208 {{#ifeq: a'b | a&#39;b | yes | no}} 209 {{#ifeq: foo | Foo | *yes | *no}} 210 !! result 211 <p>yes 212 yes 213 no 214 </p> 215 <ul><li>no</li></ul> 216 217 !! end 218 219 220 !! test 221 #iferror 222 !!input 223 {{#iferror: {{#expr: 1 + 2 }} | error | correct }} 224 {{#iferror: {{#expr: 1 + X }} | error | correct }} 225 {{#iferror: {{#expr: 1 + 2 }} | error }} 226 {{#iferror: {{#expr: 1 + X }} | error }} 227 {{#iferror: {{#expr: 1 + 2 }} }} 228 {{#iferror: {{#expr: 1 + X }} }}empty 229 !! result 230 <p>correct 231 error 232 3 233 error 234 3 235 empty 236 </p> 237 !! end 238 239 240 !! test 241 #ifexpr 242 !! input 243 {{#ifexpr: | yes | no}} 244 {{#ifexpr: 1 > 0 | yes }} 245 {{#ifexpr: 1 < 0 | yes }}empty 246 {{#ifexpr: 1 > 0 | | no}}empty 247 {{#ifexpr: 1 < 0 | | no}} 248 {{#ifexpr: 1 > 0 }}empty 249 !! result 250 <p>no 251 yes 252 empty 253 empty 254 no 255 empty 256 </p> 257 !! end 258 259 !! test 260 Bug 22866: #ifexpr should evaluate "-0" as false 261 !! input 262 {{#ifexpr: (-1)*0 | true | false }} 263 !! result 264 <p>false 265 </p> 266 !! end 267 268 !! test 269 Templates: Parser functions don't strip whitespace from positional parameters 270 !! input 271 {{#if: {{foo}} 272 | no-pre-then 273 | no-pre-else 274 }} 275 !! result 276 <p>no-pre-then 277 </p> 278 !! end 279 280 !! test 281 #switch 282 !! input 283 {{#switch:foo&bar|foo&bar=yes|no}} 284 {{#switch:foo&bar|fred=1|foo&bar|g=yes|no}} 285 {{#switch:foo&bar|fred=1|foo&'bar|g=yes|no}} 286 {{#switch:foo|bar|baz=no|*default}} 287 {{#switch:none|foo=1|bar=2|#default=no match|baz=3}} 288 {{#switch:none|foo=1|bar=2|#default=ignored|baz=3|Second default}} 289 {{#switch:|a&#39;b}} 290 !! result 291 <p>yes 292 yes 293 no 294 </p> 295 <ul><li>default</li></ul> 296 <p>no match 297 Second default 298 a&#39;b 299 </p> 300 !!end 301 302 !! test 303 #switch #default should match next and not last named parameter 304 !! input 305 <{{#switch: foo | #default | bar = DEF }}> 306 <{{#switch: foo | #default | bar = DEF | baz = GHI }}> 307 !! result 308 <p><DEF> 309 <DEF> 310 </p> 311 !! end 312 313 !! test 314 #switch should not match #default as a prefix 315 !! input 316 <{{#switch: foo | #defaultWTF? = This is crazy }}> 317 <{{#switch: foo | #defaultWTF? | bar = This is crazy }}> 318 !! result 319 <p><> 320 <> 321 </p> 322 !! end
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |