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
52      // float data
53      'float 10.5' => 10.5,
54      'float .5' => .5,
55
56      // array data
57      'empty array' => array(),
58      'int indexed array' => $index_array,
59      'associative array' => $assoc_array,
60      'nested arrays' => array('foo', $index_array, $assoc_array),
61
62      // null data
63      'uppercase NULL' => NULL,
64      'lowercase null' => null,
65
66      // boolean data
67      'lowercase true' => true,
68      'lowercase false' =>false,
69      'uppercase TRUE' =>TRUE,
70      'uppercase FALSE' =>FALSE,
71
72      // empty data
73      'empty string DQ' => "",
74      'empty string SQ' => '',
75
76      // string data
77      'string DQ' => "string",
78      'string SQ' => 'string',
79      'mixed case string' => "sTrInG",
80      'heredoc' => $heredoc,
81
82      // object data
83      'instance of classWithToString' => new classWithToString(),
84      'instance of classWithoutToString' => new classWithoutToString(),
85
86      // undefined data
87      'undefined var' => @$undefined_var,
88
89      // unset data
90      'unset var' => @$unset_var,
91
92      // resource
93      'resource' => $file_handle
94);
95
96foreach($inputs as $variation =>$timezone) {
97    echo "\n-- $variation --\n";
98	var_dump( timezone_open($timezone) );
99
100};
101
102// closing the resource
103fclose( $file_handle );
104
105?>
106===DONE===
107--EXPECTF--
108*** Testing timezone_open() : usage variation -  unexpected values to first argument $timezone***
109
110-- int 0 --
111
112Warning: timezone_open(): Unknown or bad timezone (0) in %s on line %d
113bool(false)
114
115-- int 1 --
116
117Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
118bool(false)
119
120-- int 12345 --
121
122Warning: timezone_open(): Unknown or bad timezone (12345) in %s on line %d
123bool(false)
124
125-- float 10.5 --
126
127Warning: timezone_open(): Unknown or bad timezone (10.5) in %s on line %d
128bool(false)
129
130-- float .5 --
131
132Warning: timezone_open(): Unknown or bad timezone (0.5) in %s on line %d
133bool(false)
134
135-- empty array --
136
137Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
138bool(false)
139
140-- int indexed array --
141
142Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
143bool(false)
144
145-- associative array --
146
147Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
148bool(false)
149
150-- nested arrays --
151
152Warning: timezone_open() expects parameter 1 to be string, array given in %s on line %d
153bool(false)
154
155-- uppercase NULL --
156
157Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
158bool(false)
159
160-- lowercase null --
161
162Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
163bool(false)
164
165-- lowercase true --
166
167Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
168bool(false)
169
170-- lowercase false --
171
172Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
173bool(false)
174
175-- uppercase TRUE --
176
177Warning: timezone_open(): Unknown or bad timezone (1) in %s on line %d
178bool(false)
179
180-- uppercase FALSE --
181
182Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
183bool(false)
184
185-- empty string DQ --
186
187Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
188bool(false)
189
190-- empty string SQ --
191
192Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
193bool(false)
194
195-- string DQ --
196
197Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d
198bool(false)
199
200-- string SQ --
201
202Warning: timezone_open(): Unknown or bad timezone (string) in %s on line %d
203bool(false)
204
205-- mixed case string --
206
207Warning: timezone_open(): Unknown or bad timezone (sTrInG) in %s on line %d
208bool(false)
209
210-- heredoc --
211
212Warning: timezone_open(): Unknown or bad timezone (hello world) in %s on line %d
213bool(false)
214
215-- instance of classWithToString --
216
217Warning: timezone_open(): Unknown or bad timezone (Class A object) in %s on line %d
218bool(false)
219
220-- instance of classWithoutToString --
221
222Warning: timezone_open() expects parameter 1 to be string, object given in %s on line %d
223bool(false)
224
225-- undefined var --
226
227Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
228bool(false)
229
230-- unset var --
231
232Warning: timezone_open(): Unknown or bad timezone () in %s on line %d
233bool(false)
234
235-- resource --
236
237Warning: timezone_open() expects parameter 1 to be string, resource given in %s on line %d
238bool(false)
239===DONE===
240