DateTime_modify_error.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test DateTime::modify() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : public DateTime DateTime::modify ( string $modify )
  6. * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime().
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions: public date_modify()
  9. */
  10. //Set the default time zone
  11. date_default_timezone_set("Europe/London");
  12. echo "*** Testing DateTime::modify() : error conditions ***\n";
  13. // Create a date object
  14. $object = new DateTime("2009-01-30 19:34:10");
  15. echo "\n-- Testing DateTime::modify() function with less than expected no. of arguments --\n";
  16. var_dump( $object->modify() );
  17. echo "\n-- Testing DateTime::modify() function with more than expected no. of arguments --\n";
  18. $modify = "+1 day";
  19. $extra_arg = 99;
  20. var_dump( $object->modify($modify, $extra_arg) );
  21. ?>
  22. ===DONE===
  23. --EXPECTF--
  24. *** Testing DateTime::modify() : error conditions ***
  25. -- Testing DateTime::modify() function with less than expected no. of arguments --
  26. Warning: DateTime::modify() expects exactly 1 parameter, 0 given in %s on line %d
  27. bool(false)
  28. -- Testing DateTime::modify() function with more than expected no. of arguments --
  29. Warning: DateTime::modify() expects exactly 1 parameter, 2 given in %s on line %d
  30. bool(false)
  31. ===DONE===