mail_error.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Test mail() function : error conditions
  3. --FILE--
  4. <?php
  5. /* Prototype : int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
  6. * Description: Send an email message
  7. * Source code: ext/standard/mail.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing mail() : error conditions ***\n";
  11. //Test mail with one more than the expected number of arguments
  12. echo "\n-- Testing mail() function with more than expected no. of arguments --\n";
  13. $to = 'string_val';
  14. $subject = 'string_val';
  15. $message = 'string_val';
  16. $additional_headers = 'string_val';
  17. $additional_parameters = 'string_val';
  18. $extra_arg = 10;
  19. var_dump( mail($to, $subject, $message, $additional_headers, $additional_parameters, $extra_arg) );
  20. // Testing mail with one less than the expected number of arguments
  21. echo "\n-- Testing mail() function with less than expected no. of arguments --\n";
  22. $to = 'string_val';
  23. $subject = 'string_val';
  24. var_dump( mail($to, $subject) );
  25. ?>
  26. ===DONE===
  27. --EXPECTF--
  28. *** Testing mail() : error conditions ***
  29. -- Testing mail() function with more than expected no. of arguments --
  30. Warning: mail() expects at most 5 parameters, 6 given in %s on line %d
  31. NULL
  32. -- Testing mail() function with less than expected no. of arguments --
  33. Warning: mail() expects at least 3 parameters, 2 given in %s on line %d
  34. NULL
  35. ===DONE===