Annotation of embedaddon/php/ext/imap/tests/imap_fetch_overview_variation6.phpt, revision 1.1.1.1
1.1 misho 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: /*
15: * Pass a multipart message to imap_fetch_overview() to test the contents of returned array
16: */
17:
18: echo "*** Testing imap_fetch_overview() : usage variations ***\n";
19:
20: require_once(dirname(__FILE__).'/imap_include.inc');
21:
22: $stream_id = setup_test_mailbox('', 0, $mailbox); // setup temp mailbox
23: create_multipart_message($stream_id, $mailbox);
24:
25: // refresh msg numbers
26: imap_check($stream_id);
27: $msg_no = 1;
28:
29: $a = imap_fetch_overview($stream_id, $msg_no);
30: echo "\n--> Object #1\n";
31: displayOverviewFields($a[0]);
32:
33:
34:
35:
36: /**
37: * Create a multipart message with subparts
38: *
39: * @param resource $imap_stream
40: * @param string $mailbox
41: */
42: function create_multipart_message($imap_stream, $mailbox) {
43: global $users, $domain;
44: $envelope["from"]= "foo@anywhere.com";
45: $envelope["to"] = "$users[0]@$domain";
46: $envelope["subject"] = "Test msg 1";
47:
48: $part1["type"] = TYPEMULTIPART;
49: $part1["subtype"] = "mixed";
50:
51: $part2["type"] = TYPETEXT;
52: $part2["subtype"] = "plain";
53: $part2["description"] = "imap_mail_compose() function";
54: $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx";
55:
56: $part3["type"] = TYPETEXT;
57: $part3["subtype"] = "plain";
58: $part3["description"] = "Example";
59: $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy";
60:
61: $file_handle = fopen(__FILE__, 'r+');
62: $file_size = 1;
63:
64: $part4["type"] = TYPEAPPLICATION;
65: $part4["encoding"] = ENCBASE64;
66: $part4["subtype"] = "octet-stream";
67: $part4["description"] = 'Test';
68: $part4['disposition.type'] = 'attachment';
69: $part4['disposition'] = array ('filename' => 'Test');
70: $part4['type.parameters'] = array('name' => 'Test');
71: $part4["contents.data"] = base64_encode(fread($file_handle, 1));
72:
73: $body[1] = $part1;
74: $body[2] = $part2;
75: $body[3] = $part3;
76: $body[4] = $part4;
77:
78: $msg = imap_mail_compose($envelope, $body);
79:
80: if (imap_append($imap_stream, $mailbox, $msg) === false) {
81: echo imap_last_error() . "\n";
82: echo "TEST FAILED : could not append new message to mailbox '$mailbox'\n";
83: exit;
84: }
85: }
86:
87: ?>
88: ===DONE===
89: --CLEAN--
90: <?php
91: require_once(dirname(__FILE__).'/clean.inc');
92: ?>
93: --EXPECTF--
94: *** Testing imap_fetch_overview() : usage variations ***
95: Create a temporary mailbox and add 0 msgs
96: .. mailbox '{%s}%s' created
97:
98: --> Object #1
99: size is %d
100: uid is %d
101: msgno is 1
102: recent is %d
103: flagged is 0
104: answered is 0
105: deleted is 0
106: seen is 0
107: draft is 0
108: udate is OK
109: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>