imap_fetchheader_variation5.phpt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. --TEST--
  2. Test imap_fetchheader() function : usage variations - $msg_no argument
  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. * Pass different integers and strings as $msg_no argument
  15. * to test behaviour of imap_fetchheader()
  16. */
  17. echo "*** Testing imap_fetchheader() : usage variations ***\n";
  18. require_once(dirname(__FILE__).'/imap_include.inc');
  19. $stream_id = setup_test_mailbox('', 3, $mailbox, 'notSimple'); // set up temp mailbox with 3 msgs
  20. $sequences = array (0, 4, // out of range
  21. '1,3', '1:3', // message sequences instead of numbers
  22. );
  23. foreach($sequences as $msg_no) {
  24. echo "\n-- \$msg_no is $msg_no --\n";
  25. var_dump($overview = imap_fetchheader($stream_id, $msg_no));
  26. if (!$overview) {
  27. echo imap_last_error() . "\n";
  28. }
  29. }
  30. // clear error stack
  31. imap_errors();
  32. ?>
  33. ===DONE===
  34. --CLEAN--
  35. <?php
  36. require_once(dirname(__FILE__).'/clean.inc');
  37. ?>
  38. --EXPECTF--
  39. *** Testing imap_fetchheader() : usage variations ***
  40. Create a temporary mailbox and add 3 msgs
  41. .. mailbox '{%s}%s' created
  42. -- $msg_no is 0 --
  43. Warning: imap_fetchheader(): Bad message number in %s on line %d
  44. bool(false)
  45. -- $msg_no is 4 --
  46. Warning: imap_fetchheader(): Bad message number in %s on line %d
  47. bool(false)
  48. -- $msg_no is 1,3 --
  49. Notice: A non well formed numeric value encountered in %s on line %d
  50. %unicode|string%(%d) "From: foo@anywhere.com
  51. Subject: Test msg 1
  52. To: %s
  53. MIME-Version: 1.0
  54. Content-Type: MULTIPART/mixed; BOUNDARY="%s"
  55. "
  56. -- $msg_no is 1:3 --
  57. Notice: A non well formed numeric value encountered in %s on line %d
  58. %unicode|string%(%d) "From: foo@anywhere.com
  59. Subject: Test msg 1
  60. To: %s
  61. MIME-Version: 1.0
  62. Content-Type: MULTIPART/mixed; BOUNDARY="%s"
  63. "
  64. ===DONE===