Annotation of embedaddon/php/ext/standard/tests/file/glob_variation.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test glob() function: usage variations
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') {
6: die('skip.. Not valid for Windows');
7: }
8: ?>
9: --FILE--
10: <?php
11: /* Prototype: array glob ( string $pattern [, int $flags] );
12: Description: Find pathnames matching a pattern
13: */
14:
15: echo "*** Testing glob() : usage variations ***\n";
16:
17: $file_path = dirname(__FILE__);
18:
19: // temp dir created
20: mkdir("$file_path/glob_variation");
21: mkdir("$file_path/glob_variation/wonder");
22:
23: // temp files created
24: $fp = fopen("$file_path/glob_variation/wonder12345", "w");
25: fclose($fp);
26: $fp = fopen("$file_path/glob_variation/wonder;123456", "w");
27: fclose($fp);
28:
29: $patterns = array (
30: "$file_path/glob_variation/*der*",
31: "$file_path/glob_variation/?onder*",
32: "$file_path/glob_variation/w*der?*",
33: "$file_path/glob_variation/*der5",
34: "$file_path/glob_variation/??onder*",
35: "$file_path/glob_variation/***der***",
36: "$file_path/glob_variation/++onder*",
37: "$file_path/glob_variation/WONDER5\0",
38: '$file_path/glob_variation/wonder5',
39: "$file_path/glob_variation/?wonder?",
40: "$file_path/glob_variation/wonder?",
41: TRUE // boolean true
42: );
43: $counter = 1;
44: /* loop through $patterns to match each $pattern with the files created
45: using glob() */
46: foreach($patterns as $pattern) {
47: echo "\n-- Iteration $counter --\n";
48: var_dump( glob($pattern) ); // default arguments
49: var_dump( glob($pattern, GLOB_MARK) );
50: var_dump( glob($pattern, GLOB_NOSORT) );
51: var_dump( glob($pattern, GLOB_NOCHECK) );
52: var_dump( glob($pattern, GLOB_NOESCAPE) );
53: var_dump( glob($pattern, GLOB_ERR) );
54: $counter++;
55: }
56:
57: echo "\n*** Testing glob() with pattern within braces ***\n";
58: var_dump( glob("$file_path/glob_variation/*{5}", GLOB_BRACE) );
59:
60: // delete temp files and dir
61: unlink("$file_path/glob_variation/wonder12345");
62: unlink("$file_path/glob_variation/wonder;123456");
63: rmdir("$file_path/glob_variation/wonder");
64: rmdir("$file_path/glob_variation");
65:
66: echo "\n*** Testing glob() on directories ***\n";
67: // temp dir created to check for pattern matching the sub dir created in it
68: mkdir("$file_path/glob_variation/wonder1/wonder2", 0777, true);
69:
70: $counter = 1;
71: /* loop through $patterns to match each $pattern with the directories created
72: using glob() */
73: foreach($patterns as $pattern) {
74: echo "-- Iteration $counter --\n";
75: var_dump( glob($pattern, GLOB_ONLYDIR) );
76: $counter++;
77: }
78:
79: echo "Done\n";
80: ?>
81: --CLEAN--
82: <?php
83: $file_path = dirname(__FILE__);
84: rmdir("$file_path/glob_variation/wonder1/wonder2");
85: rmdir("$file_path/glob_variation/wonder1/");
86: rmdir("$file_path/glob_variation/");
87: ?>
88: --EXPECTF--
89: *** Testing glob() : usage variations ***
90:
91: -- Iteration 1 --
92: array(3) {
93: [0]=>
94: string(%d) "%s/glob_variation/wonder"
95: [1]=>
96: string(%d) "%s/glob_variation/wonder12345"
97: [2]=>
98: string(%d) "%s/glob_variation/wonder;123456"
99: }
100: array(3) {
101: [0]=>
102: string(%d) "%s/glob_variation/wonder/"
103: [1]=>
104: string(%d) "%s/glob_variation/wonder12345"
105: [2]=>
106: string(%d) "%s/glob_variation/wonder;123456"
107: }
108: array(3) {
109: [0]=>
110: string(%d) "%s"
111: [1]=>
112: string(%d) "%s"
113: [2]=>
114: string(%d) "%s"
115: }
116: array(3) {
117: [0]=>
118: string(%d) "%s/glob_variation/wonder"
119: [1]=>
120: string(%d) "%s/glob_variation/wonder12345"
121: [2]=>
122: string(%d) "%s/glob_variation/wonder;123456"
123: }
124: array(3) {
125: [0]=>
126: string(%d) "%s/glob_variation/wonder"
127: [1]=>
128: string(%d) "%s/glob_variation/wonder12345"
129: [2]=>
130: string(%d) "%s/glob_variation/wonder;123456"
131: }
132: array(3) {
133: [0]=>
134: string(%d) "%s/glob_variation/wonder"
135: [1]=>
136: string(%d) "%s/glob_variation/wonder12345"
137: [2]=>
138: string(%d) "%s/glob_variation/wonder;123456"
139: }
140:
141: -- Iteration 2 --
142: array(3) {
143: [0]=>
144: string(%d) "%s/glob_variation/wonder"
145: [1]=>
146: string(%d) "%s/glob_variation/wonder12345"
147: [2]=>
148: string(%d) "%s/glob_variation/wonder;123456"
149: }
150: array(3) {
151: [0]=>
152: string(%d) "%s/glob_variation/wonder/"
153: [1]=>
154: string(%d) "%s/glob_variation/wonder12345"
155: [2]=>
156: string(%d) "%s/glob_variation/wonder;123456"
157: }
158: array(3) {
159: [0]=>
160: string(%d) "%s"
161: [1]=>
162: string(%d) "%s"
163: [2]=>
164: string(%d) "%s"
165: }
166: array(3) {
167: [0]=>
168: string(%d) "%s/glob_variation/wonder"
169: [1]=>
170: string(%d) "%s/glob_variation/wonder12345"
171: [2]=>
172: string(%d) "%s/glob_variation/wonder;123456"
173: }
174: array(3) {
175: [0]=>
176: string(%d) "%s/glob_variation/wonder"
177: [1]=>
178: string(%d) "%s/glob_variation/wonder12345"
179: [2]=>
180: string(%d) "%s/glob_variation/wonder;123456"
181: }
182: array(3) {
183: [0]=>
184: string(%d) "%s/glob_variation/wonder"
185: [1]=>
186: string(%d) "%s/glob_variation/wonder12345"
187: [2]=>
188: string(%d) "%s/glob_variation/wonder;123456"
189: }
190:
191: -- Iteration 3 --
192: array(2) {
193: [0]=>
194: string(%d) "%s/glob_variation/wonder12345"
195: [1]=>
196: string(%d) "%s/glob_variation/wonder;123456"
197: }
198: array(2) {
199: [0]=>
200: string(%d) "%s/glob_variation/wonder12345"
201: [1]=>
202: string(%d) "%s/glob_variation/wonder;123456"
203: }
204: array(2) {
205: [0]=>
206: string(%d) "%s"
207: [1]=>
208: string(%d) "%s"
209: }
210: array(2) {
211: [0]=>
212: string(%d) "%s/glob_variation/wonder12345"
213: [1]=>
214: string(%d) "%s/glob_variation/wonder;123456"
215: }
216: array(2) {
217: [0]=>
218: string(%d) "%s/glob_variation/wonder12345"
219: [1]=>
220: string(%d) "%s/glob_variation/wonder;123456"
221: }
222: array(2) {
223: [0]=>
224: string(%d) "%s/glob_variation/wonder12345"
225: [1]=>
226: string(%d) "%s/glob_variation/wonder;123456"
227: }
228:
229: -- Iteration 4 --
230: array(0) {
231: }
232: array(0) {
233: }
234: array(0) {
235: }
236: array(1) {
237: [0]=>
238: string(%d) "%s/glob_variation/*der5"
239: }
240: array(0) {
241: }
242: array(0) {
243: }
244:
245: -- Iteration 5 --
246: array(0) {
247: }
248: array(0) {
249: }
250: array(0) {
251: }
252: array(1) {
253: [0]=>
254: string(%d) "%s/glob_variation/??onder*"
255: }
256: array(0) {
257: }
258: array(0) {
259: }
260:
261: -- Iteration 6 --
262: array(3) {
263: [0]=>
264: string(%d) "%s/glob_variation/wonder"
265: [1]=>
266: string(%d) "%s/glob_variation/wonder12345"
267: [2]=>
268: string(%d) "%s/glob_variation/wonder;123456"
269: }
270: array(3) {
271: [0]=>
272: string(%d) "%s/glob_variation/wonder/"
273: [1]=>
274: string(%d) "%s/glob_variation/wonder12345"
275: [2]=>
276: string(%d) "%s/glob_variation/wonder;123456"
277: }
278: array(3) {
279: [0]=>
280: string(%d) "%s"
281: [1]=>
282: string(%d) "%s"
283: [2]=>
284: string(%d) "%s"
285: }
286: array(3) {
287: [0]=>
288: string(%d) "%s/glob_variation/wonder"
289: [1]=>
290: string(%d) "%s/glob_variation/wonder12345"
291: [2]=>
292: string(%d) "%s/glob_variation/wonder;123456"
293: }
294: array(3) {
295: [0]=>
296: string(%d) "%s/glob_variation/wonder"
297: [1]=>
298: string(%d) "%s/glob_variation/wonder12345"
299: [2]=>
300: string(%d) "%s/glob_variation/wonder;123456"
301: }
302: array(3) {
303: [0]=>
304: string(%d) "%s/glob_variation/wonder"
305: [1]=>
306: string(%d) "%s/glob_variation/wonder12345"
307: [2]=>
308: string(%d) "%s/glob_variation/wonder;123456"
309: }
310:
311: -- Iteration 7 --
312: array(0) {
313: }
314: array(0) {
315: }
316: array(0) {
317: }
318: array(1) {
319: [0]=>
320: string(%d) "%s/glob_variation/++onder*"
321: }
322: array(0) {
323: }
324: array(0) {
325: }
326:
327: -- Iteration 8 --
1.1.1.2 ! misho 328:
! 329: Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
! 330: NULL
! 331:
! 332: Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
! 333: NULL
! 334:
! 335: Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
! 336: NULL
! 337:
! 338: Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
! 339: NULL
! 340:
! 341: Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
! 342: NULL
! 343:
! 344: Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
! 345: NULL
1.1 misho 346:
347: -- Iteration 9 --
348: array(0) {
349: }
350: array(0) {
351: }
352: array(0) {
353: }
354: array(1) {
355: [0]=>
356: string(%d) "$file_path/glob_variation/wonder5"
357: }
358: array(0) {
359: }
360: array(0) {
361: }
362:
363: -- Iteration 10 --
364: array(0) {
365: }
366: array(0) {
367: }
368: array(0) {
369: }
370: array(1) {
371: [0]=>
372: string(%d) "%s/glob_variation/?wonder?"
373: }
374: array(0) {
375: }
376: array(0) {
377: }
378:
379: -- Iteration 11 --
380: array(0) {
381: }
382: array(0) {
383: }
384: array(0) {
385: }
386: array(1) {
387: [0]=>
388: string(%d) "%s/glob_variation/wonder?"
389: }
390: array(0) {
391: }
392: array(0) {
393: }
394:
395: -- Iteration 12 --
396: array(0) {
397: }
398: array(0) {
399: }
400: array(0) {
401: }
402: array(1) {
403: [0]=>
404: string(%d) "1"
405: }
406: array(0) {
407: }
408: array(0) {
409: }
410:
411: *** Testing glob() with pattern within braces ***
412: array(1) {
413: [0]=>
414: string(%d) "%s/glob_variation/wonder12345"
415: }
416:
417: *** Testing glob() on directories ***
418: -- Iteration 1 --
419: array(1) {
420: [0]=>
421: string(%d) "%s/glob_variation/wonder1"
422: }
423: -- Iteration 2 --
424: array(1) {
425: [0]=>
426: string(%d) "%s/glob_variation/wonder1"
427: }
428: -- Iteration 3 --
429: array(1) {
430: [0]=>
431: string(%d) "%s/glob_variation/wonder1"
432: }
433: -- Iteration 4 --
434: array(0) {
435: }
436: -- Iteration 5 --
437: array(0) {
438: }
439: -- Iteration 6 --
440: array(1) {
441: [0]=>
442: string(%d) "%s/glob_variation/wonder1"
443: }
444: -- Iteration 7 --
445: array(0) {
446: }
447: -- Iteration 8 --
1.1.1.2 ! misho 448:
! 449: Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
! 450: NULL
1.1 misho 451: -- Iteration 9 --
452: array(0) {
453: }
454: -- Iteration 10 --
455: array(0) {
456: }
457: -- Iteration 11 --
458: array(1) {
459: [0]=>
460: string(%d) "%s/glob_variation/wonder1"
461: }
462: -- Iteration 12 --
463: array(0) {
464: }
465: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>