1--TEST--
2Test imap_fetch_overview() function : usage variations - $msg_no argument
3--SKIPIF--
4<?php
5require_once(__DIR__.'/setup/skipif.inc');
6?>
7--FILE--
8<?php
9/*
10 * Pass different sequences/msg numbers as $msg_no argument to test behaviour
11 * of imap_fetch_overview()
12 */
13
14echo "*** Testing imap_fetch_overview() : usage variations ***\n";
15require_once __DIR__.'/setup/imap_include.inc';
16
17$stream_id = setup_test_mailbox('imapfetchoverviewvar5', 3, $mailbox, false); // set up temp mailbox with 3 msgs
18
19$sequences = [
20    0,
21    4, // out of range
22    '4', // out of range
23    '2',
24    '1,3',
25    '1, 2',
26    '1:3', // pass uid without setting FT_UID option
27];
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--CLEAN--
46<?php
47$mailbox_suffix = 'imapfetchoverviewvar5';
48require_once(__DIR__.'/setup/clean.inc');
49?>
50--EXPECTF--
51*** Testing imap_fetch_overview() : usage variations ***
52Create a temporary mailbox and add 3 msgs
53New mailbox 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