imap_fetch_overview_variation6.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. --TEST--
  2. Test imap_fetch_overview() function : usage variations - multipart message
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__).'/skipif.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. /* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
  10. * Description: Read an overview of the information in the headers of the given message sequence
  11. * Source code: ext/imap/php_imap.c
  12. */
  13. /*
  14. * Pass a multipart message to imap_fetch_overview() to test the contents of returned array
  15. */
  16. echo "*** Testing imap_fetch_overview() : usage variations ***\n";
  17. require_once(dirname(__FILE__).'/imap_include.inc');
  18. $stream_id = setup_test_mailbox('', 0, $mailbox); // setup temp mailbox
  19. create_multipart_message($stream_id, $mailbox);
  20. // refresh msg numbers
  21. imap_check($stream_id);
  22. $msg_no = 1;
  23. $a = imap_fetch_overview($stream_id, $msg_no);
  24. echo "\n--> Object #1\n";
  25. displayOverviewFields($a[0]);
  26. /**
  27. * Create a multipart message with subparts
  28. *
  29. * @param resource $imap_stream
  30. * @param string $mailbox
  31. */
  32. function create_multipart_message($imap_stream, $mailbox) {
  33. global $users, $domain;
  34. $envelope["from"]= "foo@anywhere.com";
  35. $envelope["to"] = "$users[0]@$domain";
  36. $envelope["subject"] = "Test msg 1";
  37. $part1["type"] = TYPEMULTIPART;
  38. $part1["subtype"] = "mixed";
  39. $part2["type"] = TYPETEXT;
  40. $part2["subtype"] = "plain";
  41. $part2["description"] = "imap_mail_compose() function";
  42. $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx";
  43. $part3["type"] = TYPETEXT;
  44. $part3["subtype"] = "plain";
  45. $part3["description"] = "Example";
  46. $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy";
  47. $file_handle = fopen(__FILE__, 'r+');
  48. $file_size = 1;
  49. $part4["type"] = TYPEAPPLICATION;
  50. $part4["encoding"] = ENCBASE64;
  51. $part4["subtype"] = "octet-stream";
  52. $part4["description"] = 'Test';
  53. $part4['disposition.type'] = 'attachment';
  54. $part4['disposition'] = array ('filename' => 'Test');
  55. $part4['type.parameters'] = array('name' => 'Test');
  56. $part4["contents.data"] = base64_encode(fread($file_handle, 1));
  57. $body[1] = $part1;
  58. $body[2] = $part2;
  59. $body[3] = $part3;
  60. $body[4] = $part4;
  61. $msg = imap_mail_compose($envelope, $body);
  62. if (imap_append($imap_stream, $mailbox, $msg) === false) {
  63. echo imap_last_error() . "\n";
  64. echo "TEST FAILED : could not append new message to mailbox '$mailbox'\n";
  65. exit;
  66. }
  67. }
  68. ?>
  69. ===DONE===
  70. --CLEAN--
  71. <?php
  72. require_once(dirname(__FILE__).'/clean.inc');
  73. ?>
  74. --EXPECTF--
  75. *** Testing imap_fetch_overview() : usage variations ***
  76. Create a temporary mailbox and add 0 msgs
  77. .. mailbox '{%s}%s' created
  78. --> Object #1
  79. size is %d
  80. uid is %d
  81. msgno is 1
  82. recent is %d
  83. flagged is 0
  84. answered is 0
  85. deleted is 0
  86. seen is 0
  87. draft is 0
  88. udate is OK
  89. ===DONE===