Annotation of embedaddon/php/ext/date/tests/timezone_offset_get_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test timezone_offset_get() function : error conditions
3: --FILE--
4: <?php
5: /* Prototype : int timezone_offset_get ( DateTimeZone $object , DateTime $datetime )
6: * Description: Returns the timezone offset from GMT
7: * Source code: ext/date/php_date.c
8: * Alias to functions: DateTimeZone::getOffset
9: */
10:
11: //Set the default time zone
12: date_default_timezone_set("GMT");
13: $tz = timezone_open("Europe/London");
14: $date = date_create("GMT");
15:
16: echo "*** Testing timezone_offset_get() : error conditions ***\n";
17:
18: echo "\n-- Testing timezone_offset_get() function with zero arguments --\n";
19: var_dump( timezone_offset_get() );
20:
21: echo "\n-- Testing timezone_offset_get() function with less than expected no. of arguments --\n";
22: var_dump( timezone_offset_get($tz) );
23:
24: echo "\n-- Testing timezone_offset_get() function with more than expected no. of arguments --\n";
25: $extra_arg = 99;
26: var_dump( timezone_offset_get($tz, $date, $extra_arg) );
27:
28: echo "\n-- Testing timezone_offset_get() function with an invalid values for \$object argument --\n";
29: $invalid_obj = new stdClass();
30: var_dump( timezone_offset_get($invalid_obj, $date) );
31: $invalid_obj = 10;
32: var_dump( timezone_offset_get($invalid_obj, $date) );
33: $invalid_obj = null;
34: var_dump( timezone_offset_get($invalid_obj, $date) );
35:
36: echo "\n-- Testing timezone_offset_get() function with an invalid values for \$datetime argument --\n";
37: $invalid_obj = new stdClass();
38: var_dump( timezone_offset_get($tz, $invalid_obj) );
39: $invalid_obj = 10;
40: var_dump( timezone_offset_get($tz, $invalid_obj) );
41: $invalid_obj = null;
42: var_dump( timezone_offset_get($tz, $invalid_obj) );
43: ?>
44: ===DONE===
45: --EXPECTF--
46: *** Testing timezone_offset_get() : error conditions ***
47:
48: -- Testing timezone_offset_get() function with zero arguments --
49:
50: Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on line %d
51: bool(false)
52:
53: -- Testing timezone_offset_get() function with less than expected no. of arguments --
54:
55: Warning: timezone_offset_get() expects exactly 2 parameters, 1 given in %s on line %d
56: bool(false)
57:
58: -- Testing timezone_offset_get() function with more than expected no. of arguments --
59:
60: Warning: timezone_offset_get() expects exactly 2 parameters, 3 given in %s on line %d
61: bool(false)
62:
63: -- Testing timezone_offset_get() function with an invalid values for $object argument --
64:
65: Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d
66: bool(false)
67:
68: Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
69: bool(false)
70:
71: Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
72: bool(false)
73:
74: -- Testing timezone_offset_get() function with an invalid values for $datetime argument --
75:
76: Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
77: bool(false)
78:
79: Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
80: bool(false)
81:
82: Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
83: bool(false)
84: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>