1--TEST--
2Test imap_fetchbody() function : basic functionality
3--SKIPIF--
4<?php
5require_once(__DIR__.'/setup/skipif.inc');
6?>
7--FILE--
8<?php
9/*           [, int $options])
10 * Description: Get a specific body section
11 * Source code: ext/imap/php_imap.c
12 */
13
14echo "*** Testing imap_fetchbody() : basic functionality ***\n";
15require_once(__DIR__.'/setup/imap_include.inc');
16
17// Initialise all required variables
18
19// set up mailbox with one message
20$stream_id = setup_test_mailbox('imapfetchbodybasic', 1, $mailbox, false);
21
22$msg_no = 1;
23$section = '2';
24$options = array ('FT_UID' => FT_UID, 'FT_PEEK' => FT_PEEK, 'FT_INTERNAL' => FT_INTERNAL);
25
26// Calling imap_fetchbody() with all possible arguments
27echo "\n-- All possible arguments --\n";
28foreach ($options as $key => $option) {
29    echo "-- Option is $key --\n";
30    switch ($key) {
31
32        case 'FT_UID';
33        $msg_uid = imap_uid($stream_id, $msg_no);
34        var_dump( imap_fetchbody($stream_id, $msg_uid, $section, $option) );
35        break;
36
37        case 'FT_PEEK';
38        var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
39        $overview = imap_fetch_overview($stream_id, 1);
40        echo "Seen Flag: ";
41        var_dump( $overview[0]->seen );
42        break;
43
44        case 'FT_INTERNAL';
45        var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
46        break;
47
48    }
49}
50
51// Calling imap_fetchbody() with mandatory arguments
52echo "\n-- Mandatory arguments --\n";
53var_dump( imap_fetchbody($stream_id, $msg_no, $section) );
54$overview = imap_fetch_overview($stream_id, 1);
55echo "Seen Flag: ";
56var_dump( $overview[0]->seen );
57?>
58--CLEAN--
59<?php
60$mailbox_suffix = 'imapfetchbodybasic';
61require_once(__DIR__.'/setup/clean.inc');
62?>
63--EXPECTF--
64*** Testing imap_fetchbody() : basic functionality ***
65Create a temporary mailbox and add 1 msgs
66New mailbox created
67
68-- All possible arguments --
69-- Option is FT_UID --
70string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
71-- Option is FT_PEEK --
72string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
73Seen Flag: int(%d)
74-- Option is FT_INTERNAL --
75string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
76
77-- Mandatory arguments --
78string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
79Seen Flag: int(%d)
80