Annotation of embedaddon/php/ext/date/tests/date_offset_get_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test date_offset_get() function : usage variation - Passing unexpected values to first argument $object.
3: --FILE--
4: <?php
5: /* Prototype : int date_offset_get ( DateTime $object )
6: * Description: Returns the daylight saving time offset
7: * Source code: ext/date/php_date.c
8: * Alias to functions: DateTime::getOffset
9: */
10:
11: echo "*** Testing date_offset_get() : usage variation - unexpected values to first argument \$object***\n";
12:
13: //Set the default time zone
14: date_default_timezone_set("Europe/London");
15:
16: //get an unset variable
17: $unset_var = 10;
18: unset ($unset_var);
19:
20: // define some classes
21: class classWithToString
22: {
23: public function __toString() {
24: return "Class A object";
25: }
26: }
27:
28: class classWithoutToString
29: {
30: }
31:
32: // heredoc string
33: $heredoc = <<<EOT
34: hello world
35: EOT;
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: foreach($inputs as $variation =>$object) {
99: echo "\n-- $variation --\n";
100: var_dump( date_offset_get($object) );
101: };
102:
103: // closing the resource
104: fclose( $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:
113: Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
114: bool(false)
115:
116: -- int 1 --
117:
118: Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
119: bool(false)
120:
121: -- int 12345 --
122:
123: Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
124: bool(false)
125:
126: -- int -12345 --
127:
128: Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
129: bool(false)
130:
131: -- float 10.5 --
132:
133: Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d
134: bool(false)
135:
136: -- float -10.5 --
137:
138: Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d
139: bool(false)
140:
141: -- float .5 --
142:
143: Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d
144: bool(false)
145:
146: -- empty array --
147:
148: Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
149: bool(false)
150:
151: -- int indexed array --
152:
153: Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
154: bool(false)
155:
156: -- associative array --
157:
158: Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
159: bool(false)
160:
161: -- nested arrays --
162:
163: Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
164: bool(false)
165:
166: -- uppercase NULL --
167:
168: Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
169: bool(false)
170:
171: -- lowercase null --
172:
173: Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
174: bool(false)
175:
176: -- lowercase true --
177:
178: Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
179: bool(false)
180:
181: -- lowercase false --
182:
183: Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
184: bool(false)
185:
186: -- uppercase TRUE --
187:
188: Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
189: bool(false)
190:
191: -- uppercase FALSE --
192:
193: Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
194: bool(false)
195:
196: -- empty string DQ --
197:
198: Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
199: bool(false)
200:
201: -- empty string SQ --
202:
203: Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
204: bool(false)
205:
206: -- string DQ --
207:
208: Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
209: bool(false)
210:
211: -- string SQ --
212:
213: Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
214: bool(false)
215:
216: -- mixed case string --
217:
218: Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
219: bool(false)
220:
221: -- heredoc --
222:
223: Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
224: bool(false)
225:
226: -- instance of classWithToString --
227:
228: Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d
229: bool(false)
230:
231: -- instance of classWithoutToString --
232:
233: Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d
234: bool(false)
235:
236: -- undefined var --
237:
238: Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
239: bool(false)
240:
241: -- unset var --
242:
243: Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
244: bool(false)
245:
246: -- resource --
247:
248: Warning: date_offset_get() expects parameter 1 to be DateTime, resource given in %s on line %d
249: bool(false)
250: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>