DateTime_construct_error.phpt 992 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Test new DateTime() : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : DateTime::__construct ([ string $time="now" [, DateTimeZone $timezone=NULL ]] )
  6. * Description: Returns new DateTime object
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. //Set the default time zone
  11. date_default_timezone_set("GMT");
  12. echo "*** Testing date_create() : error conditions ***\n";
  13. echo "\n-- Testing new DateTime() with more than expected no. of arguments --\n";
  14. $time = "GMT";
  15. $timezone = timezone_open("GMT");
  16. $extra_arg = 99;
  17. var_dump( new DateTime($time, $timezone, $extra_arg) );
  18. ?>
  19. ===DONE===
  20. --EXPECTF--
  21. *** Testing date_create() : error conditions ***
  22. -- Testing new DateTime() with more than expected no. of arguments --
  23. Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() expects at most 2 parameters, 3 given' in %s:%d
  24. Stack trace:
  25. #0 %s(%d): DateTime->__construct('GMT', Object(DateTimeZone), 99)
  26. #1 {main}
  27. thrown in %s on line %d