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