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