1--TEST--
2Test timezone_open function : usage variation - Passing unexpected values to first argument $timezone.
3--FILE--
4<?php
5/* Prototype  : DateTimeZone timezone_open  ( string $timezone  )
6 * Description: Returns new DateTimeZone object
7 * Source code: ext/date/php_date.c
8 * Alias to functions: DateTime::__construct()
9 */
10
11echo "*** Testing timezone_open() : usage variation -  unexpected values to first argument \$timezone***\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
98foreach($inputs as $variation =>$timezone) {
99    echo "\n-- $variation --\n";
100	var_dump( timezone_open($timezone) );
101
102};
103
104// closing the resource
105fclose( $file_handle );
106
107?>
108===DONE===
109--EXPECTF--
110*** Testing timezone_open() : usage variation -  unexpected values to first argument $timezone***
111
112-- int 0 --
113
114Warning: timezone_open(): Unknown or bad timezone (0) in %s on line %d
115bool(false)
116
117-- int 1 --
118
119Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
120bool(false)
121
122-- int 12345 --
123
124Warning: timezone_open(): Unknown or bad timezone (12345) in %s on line %d
125bool(false)
126
127-- int -12345 --
128
129Warning: timezone_open(): Unknown or bad timezone (-12345) in %s on line %d
130bool(false)
131
132-- float 10.5 --
133
134Warning: timezone_open(): Unknown or bad timezone (10.5) in %s on line %d
135bool(false)
136
137-- float -10.5 --
138
139Warning: timezone_open(): Unknown or bad timezone (-10.5) in %s on line %d
140bool(false)
141
142-- float .5 --
143
144Warning: timezone_open(): Unknown or bad timezone (0.5) in %s on line %d
145bool(false)
146
147-- empty array --
148
149Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
150bool(false)
151
152-- int indexed array --
153
154Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
155bool(false)
156
157-- associative array --
158
159Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
160bool(false)
161
162-- nested arrays --
163
164Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
165bool(false)
166
167-- uppercase NULL --
168
169Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
170bool(false)
171
172-- lowercase null --
173
174Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
175bool(false)
176
177-- lowercase true --
178
179Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
180bool(false)
181
182-- lowercase false --
183
184Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
185bool(false)
186
187-- uppercase TRUE --
188
189Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
190bool(false)
191
192-- uppercase FALSE --
193
194Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
195bool(false)
196
197-- empty string DQ --
198
199Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
200bool(false)
201
202-- empty string SQ --
203
204Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
205bool(false)
206
207-- string DQ --
208
209Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d
210bool(false)
211
212-- string SQ --
213
214Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d
215bool(false)
216
217-- mixed case string --
218
219Warning: timezone_open(): Unknown or bad timezone (sTrInG) in %s on line %d
220bool(false)
221
222-- heredoc --
223
224Warning: timezone_open(): Unknown or bad timezone (hello world) in %s on line %d
225bool(false)
226
227-- instance of classWithToString --
228
229Warning: timezone_open(): Unknown or bad timezone (Class A object) in %s on line %d
230bool(false)
231
232-- instance of classWithoutToString --
233
234Warning: timezone_open() expects parameter 1 to be string, object given in %s on line %d
235bool(false)
236
237-- undefined var --
238
239Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
240bool(false)
241
242-- unset var --
243
244Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
245bool(false)
246
247-- resource --
248
249Warning: timezone_open() expects parameter 1 to be string, resource given in %s on line %d
250bool(false)
251===DONE===
252