imap_fetchbody_variation6.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --TEST--
  2. Test imap_fetchbody() function : usage variations - $msg_no arg
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__).'/skipif.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. /* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section [, int $options])
  10. * Description: Get a specific body section
  11. * Source code: ext/imap/php_imap.c
  12. */
  13. /*
  14. * Pass different integers, strings, msg sequences and msg UIDs as $msg_no argument
  15. * to test behaviour of imap_fetchbody()
  16. */
  17. echo "*** Testing imap_fetchbody() : usage variations ***\n";
  18. require_once(dirname(__FILE__).'/imap_include.inc');
  19. //Initialise required variables
  20. $stream_id = setup_test_mailbox('', 3); // set up temp mailbox with simple msgs
  21. $section = 1;
  22. $sequences = array (0, 4, // out of range
  23. '1,3', '1:3', // message sequences instead of numbers
  24. );
  25. foreach($sequences as $msg_no) {
  26. echo "\n-- \$msg_no is $msg_no --\n";
  27. var_dump($overview = imap_fetchbody($stream_id, $msg_no, $section));
  28. if (!$overview) {
  29. echo imap_last_error() . "\n";
  30. }
  31. }
  32. ?>
  33. ===DONE===
  34. --CLEAN--
  35. <?php
  36. require_once(dirname(__FILE__).'/clean.inc');
  37. ?>
  38. --EXPECTF--
  39. *** Testing imap_fetchbody() : usage variations ***
  40. Create a temporary mailbox and add 3 msgs
  41. .. mailbox '{%s}%s' created
  42. -- $msg_no is 0 --
  43. Warning: imap_fetchbody(): Bad message number in %s on line %d
  44. bool(false)
  45. -- $msg_no is 4 --
  46. Warning: imap_fetchbody(): 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. string(%d) "1: this is a test message, please ignore%a"
  51. -- $msg_no is 1:3 --
  52. Notice: A non well formed numeric value encountered in %s on line %d
  53. string(%d) "1: this is a test message, please ignore%a"
  54. ===DONE===