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