1--TEST--
2Test DateTime::setISODate() function : usage variation - Passing unexpected values to first argument $year.
3--FILE--
4<?php
5/* Prototype  : public DateTime DateTime::setISODate  ( int $year  , int $week  [, int $day  ] )
6 * Description: Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
7 * Source code: ext/date/php_date.c
8 * Alias to functions: date_isodate_set
9 */
10
11echo "*** Testing DateTime::setISODate() : usage variation -  unexpected values to first argument \$year***\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$object = new DateTime("2009-02-27 08:34:10");
99$day = 2;
100$month = 7;
101
102foreach($inputs as $variation =>$year) {
103      echo "\n-- $variation --\n";
104      var_dump( $object->setISODate($year, $month, $day) );
105};
106
107// closing the resource
108fclose( $file_handle );
109
110?>
111===DONE===
112--EXPECTF--
113*** Testing DateTime::setISODate() : usage variation -  unexpected values to first argument $year***
114
115-- int 0 --
116object(DateTime)#%d (3) {
117  ["date"]=>
118  string(26) "0000-02-15 08:34:10.000000"
119  ["timezone_type"]=>
120  int(3)
121  ["timezone"]=>
122  string(13) "Europe/London"
123}
124
125-- int 1 --
126object(DateTime)#%d (3) {
127  ["date"]=>
128  string(26) "0001-02-13 08:34:10.000000"
129  ["timezone_type"]=>
130  int(3)
131  ["timezone"]=>
132  string(13) "Europe/London"
133}
134
135-- int 12345 --
136object(DateTime)#%d (3) {
137  ["date"]=>
138  string(27) "12345-02-13 08:34:10.000000"
139  ["timezone_type"]=>
140  int(3)
141  ["timezone"]=>
142  string(13) "Europe/London"
143}
144
145-- int -12345 --
146object(DateTime)#%d (3) {
147  ["date"]=>
148  string(28) "-12345-02-15 08:34:10.000000"
149  ["timezone_type"]=>
150  int(3)
151  ["timezone"]=>
152  string(13) "Europe/London"
153}
154
155-- float 10.5 --
156object(DateTime)#%d (3) {
157  ["date"]=>
158  string(26) "0010-02-16 08:34:10.000000"
159  ["timezone_type"]=>
160  int(3)
161  ["timezone"]=>
162  string(13) "Europe/London"
163}
164
165-- float -10.5 --
166object(DateTime)#%d (3) {
167  ["date"]=>
168  string(27) "-0010-02-19 08:34:10.000000"
169  ["timezone_type"]=>
170  int(3)
171  ["timezone"]=>
172  string(13) "Europe/London"
173}
174
175-- float .5 --
176object(DateTime)#%d (3) {
177  ["date"]=>
178  string(26) "0000-02-15 08:34:10.000000"
179  ["timezone_type"]=>
180  int(3)
181  ["timezone"]=>
182  string(13) "Europe/London"
183}
184
185-- empty array --
186
187Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
188bool(false)
189
190-- int indexed array --
191
192Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
193bool(false)
194
195-- associative array --
196
197Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
198bool(false)
199
200-- nested arrays --
201
202Warning: DateTime::setISODate() expects parameter 1 to be long, array given in %s on line %d
203bool(false)
204
205-- uppercase NULL --
206object(DateTime)#%d (3) {
207  ["date"]=>
208  string(26) "0000-02-15 08:34:10.000000"
209  ["timezone_type"]=>
210  int(3)
211  ["timezone"]=>
212  string(13) "Europe/London"
213}
214
215-- lowercase null --
216object(DateTime)#%d (3) {
217  ["date"]=>
218  string(26) "0000-02-15 08:34:10.000000"
219  ["timezone_type"]=>
220  int(3)
221  ["timezone"]=>
222  string(13) "Europe/London"
223}
224
225-- lowercase true --
226object(DateTime)#%d (3) {
227  ["date"]=>
228  string(26) "0001-02-13 08:34:10.000000"
229  ["timezone_type"]=>
230  int(3)
231  ["timezone"]=>
232  string(13) "Europe/London"
233}
234
235-- lowercase false --
236object(DateTime)#%d (3) {
237  ["date"]=>
238  string(26) "0000-02-15 08:34:10.000000"
239  ["timezone_type"]=>
240  int(3)
241  ["timezone"]=>
242  string(13) "Europe/London"
243}
244
245-- uppercase TRUE --
246object(DateTime)#%d (3) {
247  ["date"]=>
248  string(26) "0001-02-13 08:34:10.000000"
249  ["timezone_type"]=>
250  int(3)
251  ["timezone"]=>
252  string(13) "Europe/London"
253}
254
255-- uppercase FALSE --
256object(DateTime)#%d (3) {
257  ["date"]=>
258  string(26) "0000-02-15 08:34:10.000000"
259  ["timezone_type"]=>
260  int(3)
261  ["timezone"]=>
262  string(13) "Europe/London"
263}
264
265-- empty string DQ --
266
267Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
268bool(false)
269
270-- empty string SQ --
271
272Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
273bool(false)
274
275-- string DQ --
276
277Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
278bool(false)
279
280-- string SQ --
281
282Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
283bool(false)
284
285-- mixed case string --
286
287Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
288bool(false)
289
290-- heredoc --
291
292Warning: DateTime::setISODate() expects parameter 1 to be long, string given in %s on line %d
293bool(false)
294
295-- instance of classWithToString --
296
297Warning: DateTime::setISODate() expects parameter 1 to be long, object given in %s on line %d
298bool(false)
299
300-- instance of classWithoutToString --
301
302Warning: DateTime::setISODate() expects parameter 1 to be long, object given in %s on line %d
303bool(false)
304
305-- undefined var --
306object(DateTime)#%d (3) {
307  ["date"]=>
308  string(26) "0000-02-15 08:34:10.000000"
309  ["timezone_type"]=>
310  int(3)
311  ["timezone"]=>
312  string(13) "Europe/London"
313}
314
315-- unset var --
316object(DateTime)#%d (3) {
317  ["date"]=>
318  string(26) "0000-02-15 08:34:10.000000"
319  ["timezone_type"]=>
320  int(3)
321  ["timezone"]=>
322  string(13) "Europe/London"
323}
324
325-- resource --
326
327Warning: DateTime::setISODate() expects parameter 1 to be long, resource given in %s on line %d
328bool(false)
329===DONE===
330