1--TEST--
2Test imap_fetch_overview() function : usage variations - diff data types as $stream_id arg
3--SKIPIF--
4<?php
5extension_loaded('imap') or die('skip imap extension not available in this build');
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 data types as $stream_id argument to imap_fetch_overview() to test behaviour
17 */
18
19echo "*** Testing imap_fetch_overview() : usage variations ***\n";
20
21// Initialise function arguments not being substituted
22$msg_no = 1;
23
24//get an unset variable
25$unset_var = 10;
26unset ($unset_var);
27
28// get a class
29class classA
30{
31  public function __toString() {
32    return "Class A object";
33  }
34}
35
36// heredoc string
37$heredoc = <<<EOT
38hello world
39EOT;
40
41// unexpected values to be passed to $stream_id argument
42$inputs = array(
43
44       // int data
45/*1*/  0,
46       1,
47       12345,
48       -2345,
49
50       // float data
51/*5*/  10.5,
52       -10.5,
53       12.3456789000e10,
54       12.3456789000E-10,
55       .5,
56
57       // null data
58/*10*/ NULL,
59       null,
60
61       // boolean data
62/*12*/ true,
63       false,
64       TRUE,
65       FALSE,
66
67       // empty data
68/*16*/ "",
69       '',
70       array(),
71
72       // string data
73/*19*/ "string",
74       'string',
75       $heredoc,
76
77       // object data
78/*22*/ new classA(),
79
80       // undefined data
81/*23*/ @$undefined_var,
82
83       // unset data
84/*24*/ @$unset_var,
85);
86
87// loop through each element of $inputs to check the behavior of imap_fetch_overview()
88$iterator = 1;
89foreach($inputs as $input) {
90  echo "\n-- Testing with first argument value: ";
91  var_dump($input);
92  var_dump( imap_fetch_overview($input, $msg_no) );
93  $iterator++;
94};
95?>
96===DONE===
97--EXPECTF--
98*** Testing imap_fetch_overview() : usage variations ***
99
100-- Testing with first argument value: int(0)
101
102Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
103NULL
104
105-- Testing with first argument value: int(1)
106
107Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
108NULL
109
110-- Testing with first argument value: int(12345)
111
112Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
113NULL
114
115-- Testing with first argument value: int(-2345)
116
117Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
118NULL
119
120-- Testing with first argument value: float(10.5)
121
122Warning: imap_fetch_overview() expects parameter 1 to be resource, float given in %s on line %d
123NULL
124
125-- Testing with first argument value: float(-10.5)
126
127Warning: imap_fetch_overview() expects parameter 1 to be resource, float given in %s on line %d
128NULL
129
130-- Testing with first argument value: float(123456789000)
131
132Warning: imap_fetch_overview() expects parameter 1 to be resource, float given in %s on line %d
133NULL
134
135-- Testing with first argument value: float(1.23456789E-9)
136
137Warning: imap_fetch_overview() expects parameter 1 to be resource, float given in %s on line %d
138NULL
139
140-- Testing with first argument value: float(0.5)
141
142Warning: imap_fetch_overview() expects parameter 1 to be resource, float given in %s on line %d
143NULL
144
145-- Testing with first argument value: NULL
146
147Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
148NULL
149
150-- Testing with first argument value: NULL
151
152Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
153NULL
154
155-- Testing with first argument value: bool(true)
156
157Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
158NULL
159
160-- Testing with first argument value: bool(false)
161
162Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
163NULL
164
165-- Testing with first argument value: bool(true)
166
167Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
168NULL
169
170-- Testing with first argument value: bool(false)
171
172Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
173NULL
174
175-- Testing with first argument value: %string|unicode%(0) ""
176
177Warning: imap_fetch_overview() expects parameter 1 to be resource, string given in %s on line %d
178NULL
179
180-- Testing with first argument value: %string|unicode%(0) ""
181
182Warning: imap_fetch_overview() expects parameter 1 to be resource, string given in %s on line %d
183NULL
184
185-- Testing with first argument value: array(0) {
186}
187
188Warning: imap_fetch_overview() expects parameter 1 to be resource, array given in %s on line %d
189NULL
190
191-- Testing with first argument value: %string|unicode%(6) "string"
192
193Warning: imap_fetch_overview() expects parameter 1 to be resource, string given in %s on line %d
194NULL
195
196-- Testing with first argument value: %string|unicode%(6) "string"
197
198Warning: imap_fetch_overview() expects parameter 1 to be resource, string given in %s on line %d
199NULL
200
201-- Testing with first argument value: %string|unicode%(11) "hello world"
202
203Warning: imap_fetch_overview() expects parameter 1 to be resource, string given in %s on line %d
204NULL
205
206-- Testing with first argument value: object(classA)#1 (0) {
207}
208
209Warning: imap_fetch_overview() expects parameter 1 to be resource, object given in %s on line %d
210NULL
211
212-- Testing with first argument value: NULL
213
214Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
215NULL
216
217-- Testing with first argument value: NULL
218
219Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
220NULL
221===DONE===
222