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