Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / date / tests / DateTime_setTime_variation3.phpt
blob05bf4b5e52c5ebdaec85cb84c9bf00eeef4fda9f
1 --TEST--
2 Test DateTime::setTime() function : usage variation - Passing unexpected values to third argument $second.
3 --FILE--
4 <?php
5 /* Prototype  : public DateTime DateTime::setTime  ( 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: date_time_set
9  */
11 echo "*** Testing DateTime::setTime() : usage variation -  unexpected values to third argument \$second***\n";
13 //Set the default time zone 
14 date_default_timezone_set("Europe/London");
16 //get an unset variable
17 $unset_var = 10;
18 unset ($unset_var);
20 // define some classes
21 class classWithToString
23         public function __toString() {
24                 return "Class A object";
25         }
28 class classWithoutToString
32 // heredoc string
33 $heredoc = <<<EOT
34 hello world
35 EOT;
37 // add arrays
38 $index_array = array (1, 2, 3);
39 $assoc_array = array ('one' => 1, 'two' => 2);
41 // resource
42 $file_handle = fopen(__FILE__, 'r');
44 //array of values to iterate over
45 $inputs = array(
47       // int data
48       'int 0' => 0,
49       'int 1' => 1,
50       'int 12345' => 12345,
51       'int -12345' => -12345,
53       // float data
54       'float 10.5' => 10.5,
55       'float -10.5' => -10.5,
56       'float .5' => .5,
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),
64       // null data
65       'uppercase NULL' => NULL,
66       'lowercase null' => null,
68       // boolean data
69       'lowercase true' => true,
70       'lowercase false' =>false,
71       'uppercase TRUE' =>TRUE,
72       'uppercase FALSE' =>FALSE,
74       // empty data
75       'empty string DQ' => "",
76       'empty string SQ' => '',
78       // string data
79       'string DQ' => "string",
80       'string SQ' => 'string',
81       'mixed case string' => "sTrInG",
82       'heredoc' => $heredoc,
84       // object data
85       'instance of classWithToString' => new classWithToString(),
86       'instance of classWithoutToString' => new classWithoutToString(),
88       // undefined data
89       'undefined var' => @$undefined_var,
91       // unset data
92       'unset var' => @$unset_var,
93       
94       // resource 
95       'resource' => $file_handle
98 $object = new DateTime("2009-01-31 15:14:10");
99 $hour = 10;
100 $minute = 13;
102 foreach($inputs as $variation =>$sec) {
103       echo "\n-- $variation --\n";
104       var_dump( $object->setTime($hour, $minute, $sec) );
107 // closing the resource
108 fclose( $file_handle );
111 ===DONE===
112 --EXPECTF--
113 *** Testing DateTime::setTime() : usage variation -  unexpected values to third argument $second***
115 -- int 0 --
116 object(DateTime)#%d (3) {
117   ["date"]=>
118   string(19) "2009-01-31 10:13:00"
119   ["timezone_type"]=>
120   int(3)
121   ["timezone"]=>
122   string(13) "Europe/London"
125 -- int 1 --
126 object(DateTime)#%d (3) {
127   ["date"]=>
128   string(19) "2009-01-31 10:13:01"
129   ["timezone_type"]=>
130   int(3)
131   ["timezone"]=>
132   string(13) "Europe/London"
135 -- int 12345 --
136 object(DateTime)#%d (3) {
137   ["date"]=>
138   string(19) "2009-01-31 13:38:45"
139   ["timezone_type"]=>
140   int(3)
141   ["timezone"]=>
142   string(13) "Europe/London"
145 -- int -12345 --
146 object(DateTime)#%d (3) {
147   ["date"]=>
148   string(19) "2009-01-31 06:47:15"
149   ["timezone_type"]=>
150   int(3)
151   ["timezone"]=>
152   string(13) "Europe/London"
155 -- float 10.5 --
156 object(DateTime)#%d (3) {
157   ["date"]=>
158   string(19) "2009-01-31 10:13:10"
159   ["timezone_type"]=>
160   int(3)
161   ["timezone"]=>
162   string(13) "Europe/London"
165 -- float -10.5 --
166 object(DateTime)#%d (3) {
167   ["date"]=>
168   string(19) "2009-01-31 10:12:50"
169   ["timezone_type"]=>
170   int(3)
171   ["timezone"]=>
172   string(13) "Europe/London"
175 -- float .5 --
176 object(DateTime)#%d (3) {
177   ["date"]=>
178   string(19) "2009-01-31 10:13:00"
179   ["timezone_type"]=>
180   int(3)
181   ["timezone"]=>
182   string(13) "Europe/London"
185 -- empty array --
187 Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
188 bool(false)
190 -- int indexed array --
192 Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
193 bool(false)
195 -- associative array --
197 Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
198 bool(false)
200 -- nested arrays --
202 Warning: DateTime::setTime() expects parameter 3 to be long, array given in %s on line %d
203 bool(false)
205 -- uppercase NULL --
206 object(DateTime)#%d (3) {
207   ["date"]=>
208   string(19) "2009-01-31 10:13:00"
209   ["timezone_type"]=>
210   int(3)
211   ["timezone"]=>
212   string(13) "Europe/London"
215 -- lowercase null --
216 object(DateTime)#%d (3) {
217   ["date"]=>
218   string(19) "2009-01-31 10:13:00"
219   ["timezone_type"]=>
220   int(3)
221   ["timezone"]=>
222   string(13) "Europe/London"
225 -- lowercase true --
226 object(DateTime)#%d (3) {
227   ["date"]=>
228   string(19) "2009-01-31 10:13:01"
229   ["timezone_type"]=>
230   int(3)
231   ["timezone"]=>
232   string(13) "Europe/London"
235 -- lowercase false --
236 object(DateTime)#%d (3) {
237   ["date"]=>
238   string(19) "2009-01-31 10:13:00"
239   ["timezone_type"]=>
240   int(3)
241   ["timezone"]=>
242   string(13) "Europe/London"
245 -- uppercase TRUE --
246 object(DateTime)#%d (3) {
247   ["date"]=>
248   string(19) "2009-01-31 10:13:01"
249   ["timezone_type"]=>
250   int(3)
251   ["timezone"]=>
252   string(13) "Europe/London"
255 -- uppercase FALSE --
256 object(DateTime)#%d (3) {
257   ["date"]=>
258   string(19) "2009-01-31 10:13:00"
259   ["timezone_type"]=>
260   int(3)
261   ["timezone"]=>
262   string(13) "Europe/London"
265 -- empty string DQ --
267 Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
268 bool(false)
270 -- empty string SQ --
272 Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
273 bool(false)
275 -- string DQ --
277 Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
278 bool(false)
280 -- string SQ --
282 Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
283 bool(false)
285 -- mixed case string --
287 Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
288 bool(false)
290 -- heredoc --
292 Warning: DateTime::setTime() expects parameter 3 to be long, string given in %s on line %d
293 bool(false)
295 -- instance of classWithToString --
297 Warning: DateTime::setTime() expects parameter 3 to be long, object given in %s on line %d
298 bool(false)
300 -- instance of classWithoutToString --
302 Warning: DateTime::setTime() expects parameter 3 to be long, object given in %s on line %d
303 bool(false)
305 -- undefined var --
306 object(DateTime)#%d (3) {
307   ["date"]=>
308   string(19) "2009-01-31 10:13:00"
309   ["timezone_type"]=>
310   int(3)
311   ["timezone"]=>
312   string(13) "Europe/London"
315 -- unset var --
316 object(DateTime)#%d (3) {
317   ["date"]=>
318   string(19) "2009-01-31 10:13:00"
319   ["timezone_type"]=>
320   int(3)
321   ["timezone"]=>
322   string(13) "Europe/London"
325 -- resource --
327 Warning: DateTime::setTime() expects parameter 3 to be long, resource given in %s on line %d
328 bool(false)
329 ===DONE===