date_sunset_error.phpt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Test date_sunset() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : mixed date_sunset(mixed time [, int format [, float latitude [, float longitude [, float zenith [, float gmt_offset]]]]])
  6. * Description: Returns time of sunset for a given day and location
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing date_sunset() : error conditions ***\n";
  11. //Initialise the variables
  12. $time = time();
  13. $latitude = 38.4;
  14. $longitude = -9;
  15. $zenith = 90;
  16. $gmt_offset = 1;
  17. $extra_arg = 10;
  18. // Zero arguments
  19. echo "\n-- Testing date_sunset() function with Zero arguments --\n";
  20. var_dump( date_sunset() );
  21. //Test date_sunset with one more than the expected number of arguments
  22. echo "\n-- Testing date_sunset() function with more than expected no. of arguments --\n";
  23. var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt_offset, $extra_arg) );
  24. var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, $latitude, $longitude, $zenith, $gmt_offset, $extra_arg) );
  25. var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $latitude, $longitude, $zenith, $gmt_offset, $extra_arg) );
  26. ?>
  27. ===DONE===
  28. --EXPECTF--
  29. *** Testing date_sunset() : error conditions ***
  30. -- Testing date_sunset() function with Zero arguments --
  31. Warning: date_sunset() expects at least 1 parameter, 0 given in %s on line %d
  32. bool(false)
  33. -- Testing date_sunset() function with more than expected no. of arguments --
  34. Warning: date_sunset() expects at most 6 parameters, 7 given in %s on line %d
  35. bool(false)
  36. Warning: date_sunset() expects at most 6 parameters, 7 given in %s on line %d
  37. bool(false)
  38. Warning: date_sunset() expects at most 6 parameters, 7 given in %s on line %d
  39. bool(false)
  40. ===DONE===