1--TEST--
2Test imap_fetchheader() function : usage variations - $msg_no argument
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__).'/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
14/*
15 * Pass different integers and strings as $msg_no argument
16 * to test behaviour of imap_fetchheader()
17 */
18
19echo "*** Testing imap_fetchheader() : usage variations ***\n";
20
21require_once(dirname(__FILE__).'/imap_include.inc');
22
23$stream_id = setup_test_mailbox('', 3, $mailbox, 'notSimple'); // set up temp mailbox with 3 msgs
24
25$sequences = array (0,     4, // out of range
26                    '1,3', '1:3', // message sequences instead of numbers
27                    );
28
29foreach($sequences as $msg_no) {
30	echo "\n-- \$msg_no is $msg_no --\n";
31	var_dump($overview = imap_fetchheader($stream_id, $msg_no));
32	if (!$overview) {
33		echo imap_last_error() . "\n";
34	}
35}
36
37// clear error stack
38imap_errors();
39?>
40===DONE===
41--CLEAN--
42<?php
43require_once(dirname(__FILE__).'/clean.inc');
44?>
45--EXPECTF--
46*** Testing imap_fetchheader() : usage variations ***
47Create a temporary mailbox and add 3 msgs
48.. mailbox '{%s}%s' created
49
50-- $msg_no is 0 --
51
52Warning: imap_fetchheader(): Bad message number in %s on line %d
53bool(false)
54
55
56-- $msg_no is 4 --
57
58Warning: imap_fetchheader(): Bad message number in %s on line %d
59bool(false)
60
61
62-- $msg_no is 1,3 --
63
64Notice: A non well formed numeric value encountered in %s on line %d
65string(%d) "From: foo@anywhere.com
66Subject: Test msg 1
67To: %s
68MIME-Version: 1.0
69Content-Type: MULTIPART/mixed; BOUNDARY="%s"
70
71"
72
73-- $msg_no is 1:3 --
74
75Notice: A non well formed numeric value encountered in %s on line %d
76string(%d) "From: foo@anywhere.com
77Subject: Test msg 1
78To: %s
79MIME-Version: 1.0
80Content-Type: MULTIPART/mixed; BOUNDARY="%s"
81
82"
83===DONE===
84