imap_createmailbox_basic.phpt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --TEST--
  2. Test imap_createmailbox() function : basic functionality
  3. --EXTENSIONS--
  4. imap
  5. --SKIPIF--
  6. <?php
  7. require_once __DIR__.'/setup/skipif.inc';
  8. ?>
  9. --FILE--
  10. <?php
  11. echo "*** Testing imap_createmailbox() : basic functionality ***\n";
  12. require_once __DIR__.'/setup/imap_include.inc';
  13. $imap_stream = setup_test_mailbox("imapcreatemailboxbasic", 0);
  14. $newname = "phpnewbox";
  15. echo "Newname will be '$newname'\n";
  16. $newbox = imap_utf7_encode(IMAP_SERVER.$newname);
  17. if (imap_createmailbox($imap_stream, $newbox)) {
  18. echo "Add a couple of msgs to '$newname' mailbox\n";
  19. populate_mailbox($imap_stream, $newbox, 2);
  20. $status = imap_status($imap_stream, $newbox, SA_ALL);
  21. if ($status) {
  22. echo "Your new mailbox '$newname' has the following status:\n";
  23. echo "Messages: " . $status->messages . "\n";
  24. echo "Recent: " . $status->recent . "\n";
  25. echo "Unseen: " . $status->unseen . "\n";
  26. echo "UIDnext: " . $status->uidnext . "\n";
  27. echo "UIDvalidity: " . $status->uidvalidity . "\n";
  28. } else {
  29. echo "imap_status on new mailbox failed: " . imap_last_error() . "\n";
  30. }
  31. if (imap_deletemailbox($imap_stream, $newbox)) {
  32. echo "Mailbox '$newname' removed to restore initial state\n";
  33. } else {
  34. echo "imap_deletemailbox on new mailbox failed: " . implode("\n", imap_errors()) . "\n";
  35. }
  36. } else {
  37. echo "could not create new mailbox: " . implode("\n", imap_errors()) . "\n";
  38. }
  39. imap_close($imap_stream);
  40. ?>
  41. --CLEAN--
  42. <?php
  43. $mailbox_suffix = 'imapcreatemailboxbasic';
  44. require_once __DIR__ . '/setup/clean.inc';
  45. ?>
  46. --EXPECTF--
  47. *** Testing imap_createmailbox() : basic functionality ***
  48. Create a temporary mailbox and add 0 msgs
  49. New mailbox created
  50. Newname will be 'phpnewbox'
  51. Add a couple of msgs to 'phpnewbox' mailbox
  52. Your new mailbox 'phpnewbox' has the following status:
  53. Messages: 2
  54. Recent: 2
  55. Unseen: 2
  56. UIDnext: %d
  57. UIDvalidity: %d
  58. Mailbox 'phpnewbox' removed to restore initial state