DateTime_setDate_error.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test DateTime::setDate() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : public DateTime DateTime::setDate ( int $year , int $month , int $day )
  6. * Description: Resets the current date of the DateTime object to a different date.
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions: date_date_set()
  9. */
  10. date_default_timezone_set("Europe/London");
  11. echo "*** Testing DateTime::setDate() : error conditions ***\n";
  12. $datetime = new DateTime("2009-01-30 19:34:10");
  13. echo "\n-- Testing DateTime::setDate() function with zero arguments --\n";
  14. var_dump( $datetime->setDate() );
  15. echo "\n-- Testing DateTime::setDate() function with less than expected no. of arguments --\n";
  16. $year = 2009;
  17. $month = 1;
  18. $day = 30;
  19. var_dump( $datetime->setDate($year) );
  20. var_dump( $datetime->setDate($year, $month) );
  21. echo "\n-- Testing DateTime::setDate() function with more than expected no. of arguments --\n";
  22. $extra_arg = 10;
  23. var_dump( $datetime->setDate($year, $month, $day, $extra_arg) );
  24. ?>
  25. ===DONE===
  26. --EXPECTF--
  27. *** Testing DateTime::setDate() : error conditions ***
  28. -- Testing DateTime::setDate() function with zero arguments --
  29. Warning: DateTime::setDate() expects exactly 3 parameters, 0 given in %s on line %d
  30. bool(false)
  31. -- Testing DateTime::setDate() function with less than expected no. of arguments --
  32. Warning: DateTime::setDate() expects exactly 3 parameters, 1 given in %s on line %d
  33. bool(false)
  34. Warning: DateTime::setDate() expects exactly 3 parameters, 2 given in %s on line %d
  35. bool(false)
  36. -- Testing DateTime::setDate() function with more than expected no. of arguments --
  37. Warning: DateTime::setDate() expects exactly 3 parameters, 4 given in %s on line %d
  38. bool(false)
  39. ===DONE===