1--TEST--
2Test imap_fetch_overview() function : usage variations - $msg_no argument
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__).'/skipif.inc');
6?>
7--FILE--
8<?php
9/* Prototype  : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
10 * Description: Read an overview of the information in the headers
11 * of the given message sequence
12 * Source code: ext/imap/php_imap.c
13 */
14
15/*
16 * Pass different sequences/msg numbers as $msg_no argument to test behaviour
17 * of imap_fetch_overview()
18 */
19
20echo "*** Testing imap_fetch_overview() : usage variations ***\n";
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,     '4', // out of range
26                    '2',   '1,3', '1, 2',
27                    '1:3'); // pass uid without setting FT_UID option
28
29foreach($sequences as $msg_no) {
30	echo "\n-- \$msg_no is $msg_no --\n";
31        $overview = imap_fetch_overview($stream_id, $msg_no);
32	if (!$overview) {
33		echo imap_last_error() . "\n";
34        } else {
35		foreach($overview as $ov) {
36			echo "\n";
37			displayOverviewFields($ov);
38       		 }
39        }
40}
41
42// clear error stack
43imap_errors();
44?>
45===DONE===
46--CLEAN--
47<?php
48require_once(dirname(__FILE__).'/clean.inc');
49?>
50--EXPECTF--
51*** Testing imap_fetch_overview() : usage variations ***
52Create a temporary mailbox and add 3 msgs
53.. mailbox '{%s}%s' created
54
55-- $msg_no is 0 --
56Sequence out of range
57
58-- $msg_no is 4 --
59Sequence out of range
60
61-- $msg_no is 4 --
62Sequence out of range
63
64-- $msg_no is 2 --
65
66size is %d
67uid is %d
68msgno is 2
69recent is %d
70flagged is 0
71answered is 0
72deleted is 0
73seen is 0
74draft is 0
75udate is OK
76
77-- $msg_no is 1,3 --
78
79size is %d
80uid is %d
81msgno is 1
82recent is %d
83flagged is 0
84answered is 0
85deleted is 0
86seen is 0
87draft is 0
88udate is OK
89
90size is %d
91uid is %d
92msgno is 3
93recent is %d
94flagged is 0
95answered is 0
96deleted is 0
97seen is 0
98draft is 0
99udate is OK
100
101-- $msg_no is 1, 2 --
102Syntax error in sequence
103
104-- $msg_no is 1:3 --
105
106size is %d
107uid is %d
108msgno is 1
109recent is %d
110flagged is 0
111answered is 0
112deleted is 0
113seen is 0
114draft is 0
115udate is OK
116
117size is %d
118uid is %d
119msgno is 2
120recent is %d
121flagged is 0
122answered is 0
123deleted is 0
124seen is 0
125draft is 0
126udate is OK
127
128size is %d
129uid is %d
130msgno is 3
131recent is %d
132flagged is 0
133answered is 0
134deleted is 0
135seen is 0
136draft is 0
137udate is OK
138===DONE===
139