Annotation of embedaddon/php/ext/date/tests/date_format_error.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test 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
! 12: date_default_timezone_set("Europe/London");
! 13:
! 14: echo "*** Testing date_format() : error conditions ***\n";
! 15:
! 16: echo "\n-- Testing date_create() function with zero arguments --\n";
! 17: var_dump( date_format() );
! 18:
! 19: $date = date_create("2005-07-14 22:30:41");
! 20:
! 21: echo "\n-- Testing date_create() function with less than expected no. of arguments --\n";
! 22: var_dump( date_format($date) );
! 23:
! 24: echo "\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;
! 27: var_dump( date_format($date, $format, $extra_arg) );
! 28:
! 29: echo "\n-- Testing date_create() function with an invalid values for \$object argument --\n";
! 30: $invalid_obj = new stdClass();
! 31: var_dump( date_format($invalid_obj, $format) );
! 32: $invalid_obj = 10;
! 33: var_dump( date_format($invalid_obj, $format) );
! 34: $invalid_obj = null;
! 35: var_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:
! 44: Warning: date_format() expects exactly 2 parameters, 0 given in %s on line %d
! 45: bool(false)
! 46:
! 47: -- Testing date_create() function with less than expected no. of arguments --
! 48:
! 49: Warning: date_format() expects exactly 2 parameters, 1 given in %s on line %d
! 50: bool(false)
! 51:
! 52: -- Testing date_create() function with more than expected no. of arguments --
! 53:
! 54: Warning: date_format() expects exactly 2 parameters, 3 given in %s on line %d
! 55: bool(false)
! 56:
! 57: -- Testing date_create() function with an invalid values for $object argument --
! 58:
! 59: Warning: date_format() expects parameter 1 to be DateTime, object given in %sp on line %d
! 60: bool(false)
! 61:
! 62: Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d
! 63: bool(false)
! 64:
! 65: Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d
! 66: bool(false)
! 67: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>