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