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