1--TEST--
2Test scandir() function : usage variations - different data types as $dir arg
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') {
6  die("skip Valid only on Windows");
7}
8?>
9--FILE--
10<?php
11/* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
12 * Description: List files & directories inside the specified path
13 * Source code: ext/standard/dir.c
14 */
15
16/*
17 * Pass different data types as $dir argument to test behaviour of scandir()
18 */
19
20echo "*** Testing scandir() : usage variations ***\n";
21
22//get an unset variable
23$unset_var = 10;
24unset ($unset_var);
25
26// get a class
27class classA
28{
29  public function __toString() {
30    return "Class A object";
31  }
32}
33
34// heredoc string
35$heredoc = <<<EOT
36hello world
37EOT;
38
39// get a resource variable
40$fp = fopen(__FILE__, "r");
41
42// unexpected values to be passed to $dir argument
43$inputs = array(
44
45       // int data
46/*1*/  0,
47       1,
48       12345,
49       -2345,
50
51       // float data
52/*5*/  10.5,
53       -10.5,
54       12.3456789000e10,
55       12.3456789000E-10,
56       .5,
57
58       // null data
59/*10*/ NULL,
60       null,
61
62       // boolean data
63/*12*/ true,
64       false,
65       TRUE,
66       FALSE,
67
68       // empty data
69/*16*/ "",
70       '',
71       array(),
72
73       // string data
74/*19*/ "string",
75       'string',
76       $heredoc,
77
78       // object data
79/*22*/ new classA(),
80
81       // undefined data
82/*23*/ @$undefined_var,
83
84       // unset data
85/*24*/ @$unset_var,
86
87       // resource variable
88/*25*/ $fp
89);
90
91// loop through each element of $inputs to check the behavior of scandir()
92$iterator = 1;
93foreach($inputs as $input) {
94  echo "\n-- Iteration $iterator --\n";
95  var_dump( scandir($input) );
96  $iterator++;
97};
98
99fclose($fp);
100?>
101===DONE===
102--EXPECTF--
103*** Testing scandir() : usage variations ***
104
105-- Iteration 1 --
106
107Warning: scandir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d
108
109Warning: scandir(0): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
110
111Warning: scandir(): (errno %d): %s in %s on line %d
112bool(false)
113
114-- Iteration 2 --
115
116Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d
117
118Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
119
120Warning: scandir(): (errno %d): %s in %s on line %d
121bool(false)
122
123-- Iteration 3 --
124
125Warning: scandir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d
126
127Warning: scandir(12345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
128
129Warning: scandir(): (errno %d): %s in %s on line %d
130bool(false)
131
132-- Iteration 4 --
133
134Warning: scandir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d
135
136Warning: scandir(-2345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
137
138Warning: scandir(): (errno %d): %s in %s on line %d
139bool(false)
140
141-- Iteration 5 --
142
143Warning: scandir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d
144
145Warning: scandir(10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
146
147Warning: scandir(): (errno %d): %s in %s on line %d
148bool(false)
149
150-- Iteration 6 --
151
152Warning: scandir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d
153
154Warning: scandir(-10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
155
156Warning: scandir(): (errno %d): %s in %s on line %d
157bool(false)
158
159-- Iteration 7 --
160
161Warning: scandir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d
162
163Warning: scandir(123456789000): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
164
165Warning: scandir(): (errno %d): %s in %s on line %d
166bool(false)
167
168-- Iteration 8 --
169
170Warning: scandir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d
171
172Warning: scandir(1.23456789E-9): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
173
174Warning: scandir(): (errno %d): %s in %s on line %d
175bool(false)
176
177-- Iteration 9 --
178
179Warning: scandir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d
180
181Warning: scandir(0.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
182
183Warning: scandir(): (errno %d): %s in %s on line %d
184bool(false)
185
186-- Iteration 10 --
187
188Warning: scandir(): Directory name cannot be empty in %s on line %d
189bool(false)
190
191-- Iteration 11 --
192
193Warning: scandir(): Directory name cannot be empty in %s on line %d
194bool(false)
195
196-- Iteration 12 --
197
198Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d
199
200Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
201
202Warning: scandir(): (errno %d): %s in %s on line %d
203bool(false)
204
205-- Iteration 13 --
206
207Warning: scandir(): Directory name cannot be empty in %s on line %d
208bool(false)
209
210-- Iteration 14 --
211
212Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d
213
214Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
215
216Warning: scandir(): (errno %d): %s in %s on line %d
217bool(false)
218
219-- Iteration 15 --
220
221Warning: scandir(): Directory name cannot be empty in %s on line %d
222bool(false)
223
224-- Iteration 16 --
225
226Warning: scandir(): Directory name cannot be empty in %s on line %d
227bool(false)
228
229-- Iteration 17 --
230
231Warning: scandir(): Directory name cannot be empty in %s on line %d
232bool(false)
233
234-- Iteration 18 --
235
236Warning: scandir() expects parameter 1 to be a valid path, array given in %s on line %d
237NULL
238
239-- Iteration 19 --
240
241Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d
242
243Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
244
245Warning: scandir(): (errno %d): %s in %s on line %d
246bool(false)
247
248-- Iteration 20 --
249
250Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d
251
252Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
253
254Warning: scandir(): (errno %d): %s in %s on line %d
255bool(false)
256
257-- Iteration 21 --
258
259Warning: scandir(hello world,hello world): The system cannot find the file specified. (code: 2) in %s on line %d
260
261Warning: scandir(hello world): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
262
263Warning: scandir(): (errno %d): %s in %s on line %d
264bool(false)
265
266-- Iteration 22 --
267
268Warning: scandir(Class A object,Class A object): The system cannot find the file specified. (code: 2) in %s on line %d
269
270Warning: scandir(Class A object): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d
271
272Warning: scandir(): (errno %d): %s in %s on line %d
273bool(false)
274
275-- Iteration 23 --
276
277Warning: scandir(): Directory name cannot be empty in %s on line %d
278bool(false)
279
280-- Iteration 24 --
281
282Warning: scandir(): Directory name cannot be empty in %s on line %d
283bool(false)
284
285-- Iteration 25 --
286
287Warning: scandir() expects parameter 1 to be a valid path, resource given in %s on line %d
288NULL
289===DONE===
290