mktime_error.phpt 949 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Test mktime() function : error conditions
  3. --FILE--
  4. <?php
  5. //Set the default time zone
  6. date_default_timezone_set("Europe/London");
  7. echo "*** Testing mktime() : error conditions ***\n";
  8. echo "\n-- Testing mktime() function with Zero arguments --\n";
  9. try {
  10. var_dump( mktime() );
  11. } catch (TypeError $e) {
  12. echo $e->getMessage(), "\n";
  13. }
  14. echo "\n-- Testing mktime() function with more than expected no. of arguments --\n";
  15. $hour = 10;
  16. $minute = 30;
  17. $sec = 45;
  18. $month = 7;
  19. $day = 2;
  20. $year = 1963;
  21. $extra_arg = 10;
  22. try {
  23. var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $extra_arg) );
  24. } catch (TypeError $e) {
  25. echo $e->getMessage(), "\n";
  26. }
  27. ?>
  28. --EXPECT--
  29. *** Testing mktime() : error conditions ***
  30. -- Testing mktime() function with Zero arguments --
  31. mktime() expects at least 1 argument, 0 given
  32. -- Testing mktime() function with more than expected no. of arguments --
  33. mktime() expects at most 6 arguments, 7 given