DateTimeZone_getOffset_error.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test DateTimeZone::getOffset() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : int DateTimeZone::getOffset ( DateTime $datetime )
  6. * Description: Returns the timezone offset from GMT
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions: timezone_offset_get()
  9. */
  10. //Set the default time zone
  11. date_default_timezone_set("GMT");
  12. $tz = new DateTimeZone("Europe/London");
  13. $date = date_create("GMT");
  14. echo "*** Testing DateTimeZone::getOffset() : error conditions ***\n";
  15. echo "\n-- Testing DateTimeZone::getOffset() function with zero arguments --\n";
  16. var_dump( $tz->getOffset() );
  17. echo "\n-- Testing DateTimeZone::getOffset() function with more than expected no. of arguments --\n";
  18. $extra_arg = 99;
  19. var_dump( $tz->getOffset($date, $extra_arg) );
  20. ?>
  21. ===DONE===
  22. --EXPECTF--
  23. *** Testing DateTimeZone::getOffset() : error conditions ***
  24. -- Testing DateTimeZone::getOffset() function with zero arguments --
  25. Warning: DateTimeZone::getOffset() expects exactly 1 parameter, 0 given in %s on line %d
  26. bool(false)
  27. -- Testing DateTimeZone::getOffset() function with more than expected no. of arguments --
  28. Warning: DateTimeZone::getOffset() expects exactly 1 parameter, 2 given in %s on line %d
  29. bool(false)
  30. ===DONE===