1--TEST--
2Test timezone_transitions_get() function : usage variation - Passing unexpected values to first argument $timestamp_env.
3--FILE--
4<?php
5/* Prototype  : array timezone_transitions_get  ( DateTimeZone $object, [ int $timestamp_begin  [, int $timestamp_end  ]]  )
6 * Description: Returns all transitions for the timezone
7 * Source code: ext/date/php_date.c
8 * Alias to functions: DateTimeZone::getTransitions()
9 */
10
11echo "*** Testing timezone_transitions_get() : usage variation -  unexpected values to first argument \$timestamp_end ***\n";
12
13//Set the default time zone
14date_default_timezone_set("Europe/London");
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// resource
42$file_handle = fopen(__FILE__, 'r');
43
44//array of values to iterate over
45$inputs = array(
46
47      // int data
48      'int 0' => 0,
49      'int 1' => 1,
50      'int 12345' => 12345,
51      'int -12345' => -12345,
52
53      // float data
54      'float 10.5' => 10.5,
55      'float -10.5' => -10.5,
56      'float .5' => .5,
57
58      // array data
59      'empty array' => array(),
60      'int indexed array' => $index_array,
61      'associative array' => $assoc_array,
62      'nested arrays' => array('foo', $index_array, $assoc_array),
63
64      // null data
65      'uppercase NULL' => NULL,
66      'lowercase null' => null,
67
68      // boolean data
69      'lowercase true' => true,
70      'lowercase false' =>false,
71      'uppercase TRUE' =>TRUE,
72      'uppercase FALSE' =>FALSE,
73
74      // empty data
75      'empty string DQ' => "",
76      'empty string SQ' => '',
77
78      // string data
79      'string DQ' => "string",
80      'string SQ' => 'string',
81      'mixed case string' => "sTrInG",
82      'heredoc' => $heredoc,
83
84      // object data
85      'instance of classWithToString' => new classWithToString(),
86      'instance of classWithoutToString' => new classWithoutToString(),
87
88      // undefined data
89      'undefined var' => @$undefined_var,
90
91      // unset data
92      'unset var' => @$unset_var,
93
94      // resource
95      'resource' => $file_handle
96);
97
98$tz = timezone_open("Europe/London");
99$timestamp_begin = mktime(0, 0, 0, 1, 1, 1975);
100
101foreach($inputs as $variation =>$timestamp_end) {
102    echo "\n-- $variation --\n";
103   	$tran =  timezone_transitions_get($tz, $timestamp_begin, $timestamp_end);
104   	var_dump( gettype($tran) );
105	var_dump( count($tran) );
106};
107
108// closing the resource
109fclose( $file_handle );
110
111?>
112===DONE===
113--EXPECTF--
114*** Testing timezone_transitions_get() : usage variation -  unexpected values to first argument $timestamp_end ***
115
116-- int 0 --
117string(5) "array"
118int(1)
119
120-- int 1 --
121string(5) "array"
122int(1)
123
124-- int 12345 --
125string(5) "array"
126int(1)
127
128-- int -12345 --
129string(5) "array"
130int(1)
131
132-- float 10.5 --
133string(5) "array"
134int(1)
135
136-- float -10.5 --
137string(5) "array"
138int(1)
139
140-- float .5 --
141string(5) "array"
142int(1)
143
144-- empty array --
145
146Warning: timezone_transitions_get() expects parameter 3 to be integer, array given in %s on line %d
147string(7) "boolean"
148
149Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
150int(1)
151
152-- int indexed array --
153
154Warning: timezone_transitions_get() expects parameter 3 to be integer, array given in %s on line %d
155string(7) "boolean"
156
157Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
158int(1)
159
160-- associative array --
161
162Warning: timezone_transitions_get() expects parameter 3 to be integer, array given in %s on line %d
163string(7) "boolean"
164
165Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
166int(1)
167
168-- nested arrays --
169
170Warning: timezone_transitions_get() expects parameter 3 to be integer, array given in %s on line %d
171string(7) "boolean"
172
173Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
174int(1)
175
176-- uppercase NULL --
177string(5) "array"
178int(1)
179
180-- lowercase null --
181string(5) "array"
182int(1)
183
184-- lowercase true --
185string(5) "array"
186int(1)
187
188-- lowercase false --
189string(5) "array"
190int(1)
191
192-- uppercase TRUE --
193string(5) "array"
194int(1)
195
196-- uppercase FALSE --
197string(5) "array"
198int(1)
199
200-- empty string DQ --
201
202Warning: timezone_transitions_get() expects parameter 3 to be integer, string given in %s on line %d
203string(7) "boolean"
204
205Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
206int(1)
207
208-- empty string SQ --
209
210Warning: timezone_transitions_get() expects parameter 3 to be integer, string given in %s on line %d
211string(7) "boolean"
212
213Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
214int(1)
215
216-- string DQ --
217
218Warning: timezone_transitions_get() expects parameter 3 to be integer, string given in %s on line %d
219string(7) "boolean"
220
221Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
222int(1)
223
224-- string SQ --
225
226Warning: timezone_transitions_get() expects parameter 3 to be integer, string given in %s on line %d
227string(7) "boolean"
228
229Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
230int(1)
231
232-- mixed case string --
233
234Warning: timezone_transitions_get() expects parameter 3 to be integer, string given in %s on line %d
235string(7) "boolean"
236
237Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
238int(1)
239
240-- heredoc --
241
242Warning: timezone_transitions_get() expects parameter 3 to be integer, string given in %s on line %d
243string(7) "boolean"
244
245Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
246int(1)
247
248-- instance of classWithToString --
249
250Warning: timezone_transitions_get() expects parameter 3 to be integer, object given in %s on line %d
251string(7) "boolean"
252
253Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
254int(1)
255
256-- instance of classWithoutToString --
257
258Warning: timezone_transitions_get() expects parameter 3 to be integer, object given in %s on line %d
259string(7) "boolean"
260
261Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
262int(1)
263
264-- undefined var --
265string(5) "array"
266int(1)
267
268-- unset var --
269string(5) "array"
270int(1)
271
272-- resource --
273
274Warning: timezone_transitions_get() expects parameter 3 to be integer, resource given in %s on line %d
275string(7) "boolean"
276
277Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
278int(1)
279===DONE===
280