imap_fetchbody_basic.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. --TEST--
  2. Test imap_fetchbody() function : basic functionality
  3. --EXTENSIONS--
  4. imap
  5. --SKIPIF--
  6. <?php
  7. require_once(__DIR__.'/setup/skipif.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. /* [, int $options])
  12. * Description: Get a specific body section
  13. * Source code: ext/imap/php_imap.c
  14. */
  15. echo "*** Testing imap_fetchbody() : basic functionality ***\n";
  16. require_once(__DIR__.'/setup/imap_include.inc');
  17. // Initialise all required variables
  18. // set up mailbox with one message
  19. $stream_id = setup_test_mailbox('imapfetchbodybasic', 1, $mailbox, false);
  20. $msg_no = 1;
  21. $section = '2';
  22. $options = array ('FT_UID' => FT_UID, 'FT_PEEK' => FT_PEEK, 'FT_INTERNAL' => FT_INTERNAL);
  23. // Calling imap_fetchbody() with all possible arguments
  24. echo "\n-- All possible arguments --\n";
  25. foreach ($options as $key => $option) {
  26. echo "-- Option is $key --\n";
  27. switch ($key) {
  28. case 'FT_UID';
  29. $msg_uid = imap_uid($stream_id, $msg_no);
  30. var_dump( imap_fetchbody($stream_id, $msg_uid, $section, $option) );
  31. break;
  32. case 'FT_PEEK';
  33. var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
  34. $overview = imap_fetch_overview($stream_id, 1);
  35. echo "Seen Flag: ";
  36. var_dump( $overview[0]->seen );
  37. break;
  38. case 'FT_INTERNAL';
  39. var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
  40. break;
  41. }
  42. }
  43. // Calling imap_fetchbody() with mandatory arguments
  44. echo "\n-- Mandatory arguments --\n";
  45. var_dump( imap_fetchbody($stream_id, $msg_no, $section) );
  46. $overview = imap_fetch_overview($stream_id, 1);
  47. echo "Seen Flag: ";
  48. var_dump( $overview[0]->seen );
  49. ?>
  50. --CLEAN--
  51. <?php
  52. $mailbox_suffix = 'imapfetchbodybasic';
  53. require_once(__DIR__.'/setup/clean.inc');
  54. ?>
  55. --EXPECTF--
  56. *** Testing imap_fetchbody() : basic functionality ***
  57. Create a temporary mailbox and add 1 msgs
  58. New mailbox created
  59. -- All possible arguments --
  60. -- Option is FT_UID --
  61. string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
  62. -- Option is FT_PEEK --
  63. string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
  64. Seen Flag: int(%d)
  65. -- Option is FT_INTERNAL --
  66. string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
  67. -- Mandatory arguments --
  68. string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
  69. Seen Flag: int(%d)