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