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