1--TEST--
2Test gmstrftime() function : usage variation - Passing unexpected values to first argument 'format'.
3--FILE--
4<?php
5/* Prototype  : string gmstrftime(string format [, int timestamp])
6 * Description: Format a GMT/UCT time/date according to locale settings
7 * Source code: ext/date/php_date.c
8 * Alias to functions:
9 */
10
11echo "*** Testing gmstrftime() : usage variation ***\n";
12
13// Initialise function arguments not being substituted (if any)
14$timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
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      // int data
45      'int 0' => 0,
46      'int 1' => 1,
47      'int 12345' => 12345,
48      'int -12345' => -12345,
49
50      // float data
51      'float 10.5' => 10.5,
52      'float -10.5' => -10.5,
53      'float 12.3456789000e10' => 12.3456789000e10,
54      'float -12.3456789000e10' => -12.3456789000e10,
55      'float .5' => .5,
56
57      // array data
58      'empty array' => array(),
59      'int indexed array' => $index_array,
60      'associative array' => $assoc_array,
61      'nested arrays' => array('foo', $index_array, $assoc_array),
62
63      // null data
64      'uppercase NULL' => NULL,
65      'lowercase null' => null,
66
67      // boolean data
68      'lowercase true' => true,
69      'lowercase false' =>false,
70      'uppercase TRUE' =>TRUE,
71      'uppercase FALSE' =>FALSE,
72
73      // empty data
74      'empty string DQ' => "",
75      'empty string SQ' => '',
76
77      // object data
78      'instance of classWithToString' => new classWithToString(),
79      'instance of classWithoutToString' => new classWithoutToString(),
80
81      // undefined data
82      'undefined var' => @$undefined_var,
83
84      // unset data
85      'unset var' => @$unset_var,
86);
87
88// loop through each element of the array for format
89
90foreach($inputs as $key =>$value) {
91      echo "\n--$key--\n";
92      var_dump( gmstrftime($value) );
93      var_dump( gmstrftime($value, $timestamp) );
94};
95
96?>
97===DONE===
98--EXPECTF--
99*** Testing gmstrftime() : usage variation ***
100
101--int 0--
102string(1) "0"
103string(1) "0"
104
105--int 1--
106string(1) "1"
107string(1) "1"
108
109--int 12345--
110string(5) "12345"
111string(5) "12345"
112
113--int -12345--
114string(6) "-12345"
115string(6) "-12345"
116
117--float 10.5--
118string(4) "10.5"
119string(4) "10.5"
120
121--float -10.5--
122string(5) "-10.5"
123string(5) "-10.5"
124
125--float 12.3456789000e10--
126string(12) "123456789000"
127string(12) "123456789000"
128
129--float -12.3456789000e10--
130string(13) "-123456789000"
131string(13) "-123456789000"
132
133--float .5--
134string(3) "0.5"
135string(3) "0.5"
136
137--empty array--
138
139Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
140bool(false)
141
142Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
143bool(false)
144
145--int indexed array--
146
147Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
148bool(false)
149
150Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
151bool(false)
152
153--associative array--
154
155Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
156bool(false)
157
158Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
159bool(false)
160
161--nested arrays--
162
163Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
164bool(false)
165
166Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
167bool(false)
168
169--uppercase NULL--
170bool(false)
171bool(false)
172
173--lowercase null--
174bool(false)
175bool(false)
176
177--lowercase true--
178string(1) "1"
179string(1) "1"
180
181--lowercase false--
182bool(false)
183bool(false)
184
185--uppercase TRUE--
186string(1) "1"
187string(1) "1"
188
189--uppercase FALSE--
190bool(false)
191bool(false)
192
193--empty string DQ--
194bool(false)
195bool(false)
196
197--empty string SQ--
198bool(false)
199bool(false)
200
201--instance of classWithToString--
202string(14) "Class A object"
203string(14) "Class A object"
204
205--instance of classWithoutToString--
206
207Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
208bool(false)
209
210Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
211bool(false)
212
213--undefined var--
214bool(false)
215bool(false)
216
217--unset var--
218bool(false)
219bool(false)
220===DONE===
221