1--TEST--
2Test imap_fetchheader() function : basic function
3--SKIPIF--
4<?php
5require_once(__DIR__.'/skipif.inc');
6?>
7--FILE--
8<?php
9/* Prototype  : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
10 * Description: Get the full unfiltered header for a message
11 * Source code: ext/imap/php_imap.c
12 */
13
14echo "*** Testing imap_fetchheader() : basic functionality ***\n";
15require_once(__DIR__.'/imap_include.inc');
16
17// Initialise all required variables
18$stream_id = setup_test_mailbox('', 1, $mailbox, 'multiPart'); // setup temp mailbox with 1 msg
19$msg_no = 1;
20$options = array('FT_UID' => FT_UID, 'FT_INTERNAL' => FT_INTERNAL,
21                 'FT_PREFETCHTEXT' => FT_PREFETCHTEXT);
22
23// Calling imap_fetchheader() with all possible arguments
24echo "\n-- All possible arguments --\n";
25foreach ($options as $key => $option) {
26	echo "-- Option is $key --\n";
27	if ($key == 'FT_UID') {
28		$msg_uid = imap_uid($stream_id, $msg_no);
29		var_dump(imap_fetchheader($stream_id, $msg_uid, $option));
30	} else {
31		var_dump(imap_fetchheader($stream_id, $msg_no, $option));
32	}
33}
34
35// Calling imap_fetchheader() with mandatory arguments
36echo "\n-- Mandatory arguments --\n";
37var_dump( imap_fetchheader($stream_id, $msg_no) );
38?>
39===DONE===
40--CLEAN--
41<?php
42require_once(__DIR__.'/clean.inc');
43?>
44--EXPECTF--
45*** Testing imap_fetchheader() : basic functionality ***
46Create a temporary mailbox and add 1 msgs
47.. mailbox '%s.phpttest' created
48
49-- All possible arguments --
50-- Option is FT_UID --
51string(%d) "From: foo@anywhere.com
52Subject: Test msg 1
53To: %s
54MIME-Version: 1.0
55Content-Type: %s; %s
56
57"
58-- Option is FT_INTERNAL --
59string(%d) "From: foo@anywhere.com
60Subject: Test msg 1
61To: %s
62MIME-Version: 1.0
63Content-Type: %s; %s
64
65"
66-- Option is FT_PREFETCHTEXT --
67string(%d) "From: foo@anywhere.com
68Subject: Test msg 1
69To: %s
70MIME-Version: 1.0
71Content-Type: %s; %s
72
73"
74
75-- Mandatory arguments --
76string(%d) "From: foo@anywhere.com
77Subject: Test msg 1
78To: %s
79MIME-Version: 1.0
80Content-Type: %s; %s
81
82"
83===DONE===
84