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