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