1--TEST--
2Test date_time_set() function : error conditions
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
11date_default_timezone_set("Europe/London");
12
13echo "*** Testing date_time_set() : error conditions ***\n";
14
15echo "\n-- Testing date_time_set() function with zero arguments --\n";
16var_dump( date_time_set() );
17
18echo "\n-- Testing date_time_set() function with less than expected no. of arguments --\n";
19$datetime = date_create("2009-01-31 15:34:10");
20$hour = 18;
21var_dump( date_time_set($datetime) );
22var_dump( date_time_set($datetime, $hour) );
23
24echo "\n-- Testing date_time_set() function with more than expected no. of arguments --\n";
25$min = 15;
26$sec = 30;
27$extra_arg = 10;
28var_dump( date_time_set($datetime, $hour, $min, $sec, $extra_arg) );
29
30echo "\n-- Testing date_time_set() function with an invalid values for \$object argument --\n";
31$invalid_obj = new stdClass();
32var_dump( date_time_set($invalid_obj, $hour, $min, $sec) );
33$invalid_obj = 10;
34var_dump( date_time_set($invalid_obj, $hour, $min, $sec) );
35$invalid_obj = null;
36var_dump( date_time_set($invalid_obj, $hour, $min, $sec) );
37?>
38===DONE===
39--EXPECTF--
40*** Testing date_time_set() : error conditions ***
41
42-- Testing date_time_set() function with zero arguments --
43
44Warning: date_time_set() expects at least 3 parameters, 0 given in %s on line %d
45bool(false)
46
47-- Testing date_time_set() function with less than expected no. of arguments --
48
49Warning: date_time_set() expects at least 3 parameters, 1 given in %s on line %d
50bool(false)
51
52Warning: date_time_set() expects at least 3 parameters, 2 given in %s on line %d
53bool(false)
54
55-- Testing date_time_set() function with more than expected no. of arguments --
56
57Warning: date_time_set() expects at most 4 parameters, 5 given in %s on line %d
58bool(false)
59
60-- Testing date_time_set() function with an invalid values for $object argument --
61
62Warning: date_time_set() expects parameter 1 to be DateTime, object given in %s on line %d
63bool(false)
64
65Warning: date_time_set() expects parameter 1 to be DateTime, integer given in %s on line %d
66bool(false)
67
68Warning: date_time_set() expects parameter 1 to be DateTime, null given in %s on line %d
69bool(false)
70===DONE===
71