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