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