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