imap_fetchheader_variation3.phpt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. Test imap_fetchheader() function : usage variations - FT_UID option
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__).'/skipif.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. /* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
  10. * Description: Get the full unfiltered header for a message
  11. * Source code: ext/imap/php_imap.c
  12. */
  13. /*
  14. * Test if FT_UID is set by passing the following as $options argument to imap_fetchheader():
  15. * 1. values that equate to 1
  16. * 2. Minimum and maximum PHP values
  17. */
  18. echo "*** Testing imap_fetchheader() : usage variations ***\n";
  19. require_once(dirname(__FILE__).'/imap_include.inc');
  20. // Initialise required variables
  21. $stream_id = setup_test_mailbox('', 1); // set up temporary mailbox with one simple message
  22. $msg_no = 1;
  23. $msg_uid = imap_uid($stream_id, $msg_no);
  24. $options = array ('1', true,
  25. 1.000000000000001, 0.00001e5,
  26. PHP_INT_MAX, -PHP_INT_MAX);
  27. // iterate over each element of $options array to test whether FT_UID is set
  28. $iterator = 1;
  29. imap_check($stream_id);
  30. foreach($options as $option) {
  31. echo "\n-- Iteration $iterator --\n";
  32. if(is_string(imap_fetchheader($stream_id, $msg_uid, $option))) {
  33. echo "FT_UID valid\n";
  34. } else {
  35. echo "FT_UID not valid\n";
  36. }
  37. $iterator++;
  38. }
  39. ?>
  40. ===DONE===
  41. --CLEAN--
  42. <?php
  43. require_once(dirname(__FILE__).'/clean.inc');
  44. ?>
  45. --EXPECTF--
  46. *** Testing imap_fetchheader() : usage variations ***
  47. Create a temporary mailbox and add 1 msgs
  48. .. mailbox '{%s}%s' created
  49. -- Iteration 1 --
  50. FT_UID valid
  51. -- Iteration 2 --
  52. FT_UID valid
  53. -- Iteration 3 --
  54. FT_UID valid
  55. -- Iteration 4 --
  56. FT_UID valid
  57. -- Iteration 5 --
  58. Warning: imap_fetchheader(): invalid value for the options parameter in %s on line %d
  59. FT_UID not valid
  60. -- Iteration 6 --
  61. Warning: imap_fetchheader(): invalid value for the options parameter in %s on line %d
  62. FT_UID not valid
  63. ===DONE===