1--TEST--
2Test gmstrftime() function : usage variation - Passing unexpected values to second argument 'timestamp'.
3--SKIPIF--
4<?php
5if(PHP_INT_SIZE != 4 ) {
6  die("skip Test is not valid for 64-bit");
7}
8?>
9--FILE--
10<?php
11/* Prototype  : string gmstrftime(string format [, int timestamp])
12 * Description: Format a GMT/UCT time/date according to locale settings
13 * Source code: ext/date/php_date.c
14 * Alias to functions:
15 */
16
17echo "*** Testing gmstrftime() : usage variation ***\n";
18
19date_default_timezone_set("Asia/Calcutta");
20
21// Initialise function arguments not being substituted (if any)
22$format = '%b %d %Y %H:%M:%S';
23
24//get an unset variable
25$unset_var = 10;
26unset ($unset_var);
27
28// define some classes
29class classWithToString
30{
31	public function __toString() {
32		return "Class A object";
33	}
34}
35
36class classWithoutToString
37{
38}
39
40// heredoc string
41$heredoc = <<<EOT
42hello world
43EOT;
44
45// add arrays
46$index_array = array (1, 2, 3);
47$assoc_array = array ('one' => 1, 'two' => 2);
48
49//array of values to iterate over
50$inputs = array(
51
52      // float data
53      'float 10.5' => 10.5,
54      'float -10.5' => -10.5,
55      'float 12.3456789000e10' => 12.3456789000e10,
56      'float -12.3456789000e10' => -12.3456789000e10,
57      'float .5' => .5,
58
59      // array data
60      'empty array' => array(),
61      'int indexed array' => $index_array,
62      'associative array' => $assoc_array,
63      'nested arrays' => array('foo', $index_array, $assoc_array),
64
65      // null data
66      'uppercase NULL' => NULL,
67      'lowercase null' => null,
68
69      // boolean data
70      'lowercase true' => true,
71      'lowercase false' =>false,
72      'uppercase TRUE' =>TRUE,
73      'uppercase FALSE' =>FALSE,
74
75      // empty data
76      'empty string DQ' => "",
77      'empty string SQ' => '',
78
79      // string data
80      'string DQ' => "string",
81      'string SQ' => 'string',
82      'mixed case string' => "sTrInG",
83      'heredoc' => $heredoc,
84
85      // object data
86      'instance of classWithToString' => new classWithToString(),
87      'instance of classWithoutToString' => new classWithoutToString(),
88
89      // undefined data
90      'undefined var' => @$undefined_var,
91
92      // unset data
93      'unset var' => @$unset_var,
94);
95
96// loop through each element of the array for timestamp
97
98foreach($inputs as $key =>$value) {
99      echo "\n--$key--\n";
100      var_dump( gmstrftime($format, $value) );
101};
102
103?>
104===DONE===
105--EXPECTF--
106*** Testing gmstrftime() : usage variation ***
107
108--float 10.5--
109string(20) "Jan 01 1970 00:00:10"
110
111--float -10.5--
112string(20) "Dec 31 1969 23:59:50"
113
114--float 12.3456789000e10--
115
116Warning: gmstrftime() expects parameter 2 to be integer, float given in %s on line %d
117bool(false)
118
119--float -12.3456789000e10--
120
121Warning: gmstrftime() expects parameter 2 to be integer, float given in %s on line %d
122bool(false)
123
124--float .5--
125string(20) "Jan 01 1970 00:00:00"
126
127--empty array--
128
129Warning: gmstrftime() expects parameter 2 to be integer, array given in %s on line %d
130bool(false)
131
132--int indexed array--
133
134Warning: gmstrftime() expects parameter 2 to be integer, array given in %s on line %d
135bool(false)
136
137--associative array--
138
139Warning: gmstrftime() expects parameter 2 to be integer, array given in %s on line %d
140bool(false)
141
142--nested arrays--
143
144Warning: gmstrftime() expects parameter 2 to be integer, array given in %s on line %d
145bool(false)
146
147--uppercase NULL--
148string(20) "Jan 01 1970 00:00:00"
149
150--lowercase null--
151string(20) "Jan 01 1970 00:00:00"
152
153--lowercase true--
154string(20) "Jan 01 1970 00:00:01"
155
156--lowercase false--
157string(20) "Jan 01 1970 00:00:00"
158
159--uppercase TRUE--
160string(20) "Jan 01 1970 00:00:01"
161
162--uppercase FALSE--
163string(20) "Jan 01 1970 00:00:00"
164
165--empty string DQ--
166
167Warning: gmstrftime() expects parameter 2 to be integer, string given in %s on line %d
168bool(false)
169
170--empty string SQ--
171
172Warning: gmstrftime() expects parameter 2 to be integer, string given in %s on line %d
173bool(false)
174
175--string DQ--
176
177Warning: gmstrftime() expects parameter 2 to be integer, string given in %s on line %d
178bool(false)
179
180--string SQ--
181
182Warning: gmstrftime() expects parameter 2 to be integer, string given in %s on line %d
183bool(false)
184
185--mixed case string--
186
187Warning: gmstrftime() expects parameter 2 to be integer, string given in %s on line %d
188bool(false)
189
190--heredoc--
191
192Warning: gmstrftime() expects parameter 2 to be integer, string given in %s on line %d
193bool(false)
194
195--instance of classWithToString--
196
197Warning: gmstrftime() expects parameter 2 to be integer, object given in %s on line %d
198bool(false)
199
200--instance of classWithoutToString--
201
202Warning: gmstrftime() expects parameter 2 to be integer, object given in %s on line %d
203bool(false)
204
205--undefined var--
206string(20) "Jan 01 1970 00:00:00"
207
208--unset var--
209string(20) "Jan 01 1970 00:00:00"
210===DONE===
211