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