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