1--TEST--
2Test date_timezone_set() function : error conditions
3--FILE--
4<?php
5/* Prototype  : DateTime date_timezone_set  ( DateTime $object  , DateTimeZone $timezone  )
6 * Description: Sets the time zone for the DateTime object
7 * Source code: ext/date/php_date.c
8 * Alias to functions: DateTime::setTimezone
9 */
10
11date_default_timezone_set("UTC");
12
13echo "*** Testing date_timezone_set() : error conditions ***\n";
14
15echo "\n-- Testing date_timezone_set() function with zero arguments --\n";
16var_dump( date_timezone_set() );
17
18echo "\n-- Testing date_timezone_set() function with less than expected no. of arguments --\n";
19$datetime = date_create("2009-01-30 17:57:32");
20var_dump( date_timezone_set($datetime) );
21
22echo "\n-- Testing date_timezone_set() function with more than expected no. of arguments --\n";
23$timezone  = timezone_open("GMT");
24$extra_arg = 99;
25var_dump( date_timezone_set($datetime, $timezone, $extra_arg) );
26
27echo "\n-- Testing date_timezone_set() function with an invalid values for \$object argument --\n";
28$invalid_obj = new stdClass();
29var_dump( date_timezone_set($invalid_obj, $timezone) );
30$invalid_obj = 10;
31var_dump( date_timezone_set($invalid_obj, $timezone) );
32$invalid_obj = null;
33var_dump( date_timezone_set($invalid_obj, $timezone) );
34?>
35===DONE===
36--EXPECTF--
37*** Testing date_timezone_set() : error conditions ***
38
39-- Testing date_timezone_set() function with zero arguments --
40
41Warning: date_timezone_set() expects exactly 2 parameters, 0 given in %s on line %d
42bool(false)
43
44-- Testing date_timezone_set() function with less than expected no. of arguments --
45
46Warning: date_timezone_set() expects exactly 2 parameters, 1 given in %s on line %d
47bool(false)
48
49-- Testing date_timezone_set() function with more than expected no. of arguments --
50
51Warning: date_timezone_set() expects exactly 2 parameters, 3 given in %s on line %d
52bool(false)
53
54-- Testing date_timezone_set() function with an invalid values for $object argument --
55
56Warning: date_timezone_set() expects parameter 1 to be DateTime, object given in %s on line %d
57bool(false)
58
59Warning: date_timezone_set() expects parameter 1 to be DateTime, integer given in %s on line %d
60bool(false)
61
62Warning: date_timezone_set() expects parameter 1 to be DateTime, null given in %s on line %d
63bool(false)
64===DONE===
65