Annotation of embedaddon/php/ext/imap/tests/imap_createmailbox_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test imap_createmailbox() function : basic functionality
3: --SKIPIF--
4: <?php
5: require_once(dirname(__FILE__).'/skipif.inc');
6: ?>
7: --FILE--
8: <?php
9: /* Prototype : bool imap_createmailbox ( resource $imap_stream , string $mailbox )
10: * Description: Creates a new mailbox specified by mailbox .
11: * Source code: ext/imap/php_imap.c
12: */
13:
14: echo "*** Testing imap_createmailbox() : basic functionality ***\n";
15:
16: require_once(dirname(__FILE__).'/imap_include.inc');
17:
18: $imap_stream = imap_open($default_mailbox, $username, $password) or
19: die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
20:
21: $newname = "phpnewbox";
22:
23: echo "Newname will be '$newname'\n";
24:
25: $newbox = imap_utf7_encode($server.$newname);
26: if (imap_createmailbox($imap_stream, $newbox)) {
27:
28: echo "Add a couple of msgs to '$newname' mailbox\n";
29: populate_mailbox($imap_stream, $newbox, 2);
30:
31: $status = imap_status($imap_stream, $newbox, SA_ALL);
32: if ($status) {
33: echo "Your new mailbox '$newname' has the following status:\n";
34: echo "Messages: " . $status->messages . "\n";
35: echo "Recent: " . $status->recent . "\n";
36: echo "Unseen: " . $status->unseen . "\n";
37: echo "UIDnext: " . $status->uidnext . "\n";
38: echo "UIDvalidity: " . $status->uidvalidity . "\n";
39:
40: } else {
41: echo "imap_status on new mailbox failed: " . imap_last_error() . "\n";
42: }
43:
44: if (imap_deletemailbox($imap_stream, $newbox)) {
45: echo "Mailbox '$newname' removed to restore initial state\n";
46: } else {
47: echo "imap_deletemailbox on new mailbox failed: " . implode("\n", imap_errors()) . "\n";
48: }
49:
50: } else {
51: echo "could not create new mailbox: " . implode("\n", imap_errors()) . "\n";
52: }
53:
54: imap_close($imap_stream);
55:
56: ?>
57: ===Done===
58: --EXPECTF--
59: *** Testing imap_createmailbox() : basic functionality ***
60: Newname will be 'phpnewbox'
61: Add a couple of msgs to 'phpnewbox' mailbox
62: Your new mailbox 'phpnewbox' has the following status:
63: Messages: 2
64: Recent: 2
65: Unseen: 2
66: UIDnext: %d
67: UIDvalidity: %d
68: Mailbox 'phpnewbox' removed to restore initial state
69: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>