1--TEST--
2Test getdate() function : usage variation - Passing unexpected values to first argument timestamp.
3--FILE--
4<?php
5/* Prototype  : array getdate([int timestamp])
6 * Description: Get date/time information
7 * Source code: ext/date/php_date.c
8 * Alias to functions:
9 */
10
11echo "*** Testing getdate() : usage variation ***\n";
12
13//Set the default time zone
14date_default_timezone_set("Asia/Calcutta");
15
16//get an unset variable
17$unset_var = 10;
18unset ($unset_var);
19
20// define some classes
21class classWithToString
22{
23	public function __toString() {
24		return "Class A object";
25	}
26}
27
28class classWithoutToString
29{
30}
31
32// heredoc string
33$heredoc = <<<EOT
34hello world
35EOT;
36
37// add arrays
38$index_array = array (1, 2, 3);
39$assoc_array = array ('one' => 1, 'two' => 2);
40
41//array of values to iterate over
42$inputs = array(
43
44      // float data
45      'float 10.5' => 10.5,
46      'float -10.5' => -10.5,
47      'float .5' => .5,
48
49      // array data
50      'empty array' => array(),
51      'int indexed array' => $index_array,
52      'associative array' => $assoc_array,
53      'nested arrays' => array('foo', $index_array, $assoc_array),
54
55      // null data
56      'uppercase NULL' => NULL,
57      'lowercase null' => null,
58
59      // boolean data
60      'lowercase true' => true,
61      'lowercase false' =>false,
62      'uppercase TRUE' =>TRUE,
63      'uppercase FALSE' =>FALSE,
64
65      // empty data
66      'empty string DQ' => "",
67      'empty string SQ' => '',
68
69      // string data
70      'string DQ' => "string",
71      'string SQ' => 'string',
72      'mixed case string' => "sTrInG",
73      'heredoc' => $heredoc,
74
75      // object data
76      'instance of classWithToString' => new classWithToString(),
77      'instance of classWithoutToString' => new classWithoutToString(),
78
79      // undefined data
80      'undefined var' => @$undefined_var,
81
82      // unset data
83      'unset var' => @$unset_var,
84);
85
86// loop through each element of the array for timestamp
87
88foreach($inputs as $key =>$value) {
89      echo "\n--$key--\n";
90      var_dump( getdate($value) );
91};
92
93?>
94===DONE===
95--EXPECTF--
96*** Testing getdate() : usage variation ***
97
98--float 10.5--
99array(11) {
100  ["seconds"]=>
101  int(10)
102  ["minutes"]=>
103  int(30)
104  ["hours"]=>
105  int(5)
106  ["mday"]=>
107  int(1)
108  ["wday"]=>
109  int(4)
110  ["mon"]=>
111  int(1)
112  ["year"]=>
113  int(1970)
114  ["yday"]=>
115  int(0)
116  ["weekday"]=>
117  string(8) "Thursday"
118  ["month"]=>
119  string(7) "January"
120  [0]=>
121  int(10)
122}
123
124--float -10.5--
125array(11) {
126  ["seconds"]=>
127  int(50)
128  ["minutes"]=>
129  int(29)
130  ["hours"]=>
131  int(5)
132  ["mday"]=>
133  int(1)
134  ["wday"]=>
135  int(4)
136  ["mon"]=>
137  int(1)
138  ["year"]=>
139  int(1970)
140  ["yday"]=>
141  int(0)
142  ["weekday"]=>
143  string(8) "Thursday"
144  ["month"]=>
145  string(7) "January"
146  [0]=>
147  int(-10)
148}
149
150--float .5--
151array(11) {
152  ["seconds"]=>
153  int(0)
154  ["minutes"]=>
155  int(30)
156  ["hours"]=>
157  int(5)
158  ["mday"]=>
159  int(1)
160  ["wday"]=>
161  int(4)
162  ["mon"]=>
163  int(1)
164  ["year"]=>
165  int(1970)
166  ["yday"]=>
167  int(0)
168  ["weekday"]=>
169  string(8) "Thursday"
170  ["month"]=>
171  string(7) "January"
172  [0]=>
173  int(0)
174}
175
176--empty array--
177
178Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
179bool(false)
180
181--int indexed array--
182
183Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
184bool(false)
185
186--associative array--
187
188Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
189bool(false)
190
191--nested arrays--
192
193Warning: getdate() expects parameter 1 to be long, array given in %s on line %d
194bool(false)
195
196--uppercase NULL--
197array(11) {
198  ["seconds"]=>
199  int(0)
200  ["minutes"]=>
201  int(30)
202  ["hours"]=>
203  int(5)
204  ["mday"]=>
205  int(1)
206  ["wday"]=>
207  int(4)
208  ["mon"]=>
209  int(1)
210  ["year"]=>
211  int(1970)
212  ["yday"]=>
213  int(0)
214  ["weekday"]=>
215  string(8) "Thursday"
216  ["month"]=>
217  string(7) "January"
218  [0]=>
219  int(0)
220}
221
222--lowercase null--
223array(11) {
224  ["seconds"]=>
225  int(0)
226  ["minutes"]=>
227  int(30)
228  ["hours"]=>
229  int(5)
230  ["mday"]=>
231  int(1)
232  ["wday"]=>
233  int(4)
234  ["mon"]=>
235  int(1)
236  ["year"]=>
237  int(1970)
238  ["yday"]=>
239  int(0)
240  ["weekday"]=>
241  string(8) "Thursday"
242  ["month"]=>
243  string(7) "January"
244  [0]=>
245  int(0)
246}
247
248--lowercase true--
249array(11) {
250  ["seconds"]=>
251  int(1)
252  ["minutes"]=>
253  int(30)
254  ["hours"]=>
255  int(5)
256  ["mday"]=>
257  int(1)
258  ["wday"]=>
259  int(4)
260  ["mon"]=>
261  int(1)
262  ["year"]=>
263  int(1970)
264  ["yday"]=>
265  int(0)
266  ["weekday"]=>
267  string(8) "Thursday"
268  ["month"]=>
269  string(7) "January"
270  [0]=>
271  int(1)
272}
273
274--lowercase false--
275array(11) {
276  ["seconds"]=>
277  int(0)
278  ["minutes"]=>
279  int(30)
280  ["hours"]=>
281  int(5)
282  ["mday"]=>
283  int(1)
284  ["wday"]=>
285  int(4)
286  ["mon"]=>
287  int(1)
288  ["year"]=>
289  int(1970)
290  ["yday"]=>
291  int(0)
292  ["weekday"]=>
293  string(8) "Thursday"
294  ["month"]=>
295  string(7) "January"
296  [0]=>
297  int(0)
298}
299
300--uppercase TRUE--
301array(11) {
302  ["seconds"]=>
303  int(1)
304  ["minutes"]=>
305  int(30)
306  ["hours"]=>
307  int(5)
308  ["mday"]=>
309  int(1)
310  ["wday"]=>
311  int(4)
312  ["mon"]=>
313  int(1)
314  ["year"]=>
315  int(1970)
316  ["yday"]=>
317  int(0)
318  ["weekday"]=>
319  string(8) "Thursday"
320  ["month"]=>
321  string(7) "January"
322  [0]=>
323  int(1)
324}
325
326--uppercase FALSE--
327array(11) {
328  ["seconds"]=>
329  int(0)
330  ["minutes"]=>
331  int(30)
332  ["hours"]=>
333  int(5)
334  ["mday"]=>
335  int(1)
336  ["wday"]=>
337  int(4)
338  ["mon"]=>
339  int(1)
340  ["year"]=>
341  int(1970)
342  ["yday"]=>
343  int(0)
344  ["weekday"]=>
345  string(8) "Thursday"
346  ["month"]=>
347  string(7) "January"
348  [0]=>
349  int(0)
350}
351
352--empty string DQ--
353
354Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
355bool(false)
356
357--empty string SQ--
358
359Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
360bool(false)
361
362--string DQ--
363
364Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
365bool(false)
366
367--string SQ--
368
369Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
370bool(false)
371
372--mixed case string--
373
374Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
375bool(false)
376
377--heredoc--
378
379Warning: getdate() expects parameter 1 to be long, string given in %s on line %d
380bool(false)
381
382--instance of classWithToString--
383
384Warning: getdate() expects parameter 1 to be long, object given in %s on line %d
385bool(false)
386
387--instance of classWithoutToString--
388
389Warning: getdate() expects parameter 1 to be long, object given in %s on line %d
390bool(false)
391
392--undefined var--
393array(11) {
394  ["seconds"]=>
395  int(0)
396  ["minutes"]=>
397  int(30)
398  ["hours"]=>
399  int(5)
400  ["mday"]=>
401  int(1)
402  ["wday"]=>
403  int(4)
404  ["mon"]=>
405  int(1)
406  ["year"]=>
407  int(1970)
408  ["yday"]=>
409  int(0)
410  ["weekday"]=>
411  string(8) "Thursday"
412  ["month"]=>
413  string(7) "January"
414  [0]=>
415  int(0)
416}
417
418--unset var--
419array(11) {
420  ["seconds"]=>
421  int(0)
422  ["minutes"]=>
423  int(30)
424  ["hours"]=>
425  int(5)
426  ["mday"]=>
427  int(1)
428  ["wday"]=>
429  int(4)
430  ["mon"]=>
431  int(1)
432  ["year"]=>
433  int(1970)
434  ["yday"]=>
435  int(0)
436  ["weekday"]=>
437  string(8) "Thursday"
438  ["month"]=>
439  string(7) "January"
440  [0]=>
441  int(0)
442}
443===DONE===
444