1--TEST--
2Test readdir() function : basic functionality
3--FILE--
4<?php
5/*
6 * Test basic functionality of readdir()
7 */
8
9echo "*** Testing readdir() : basic functionality ***\n";
10
11// include the file.inc for Function: function create_files()
12chdir(__DIR__);
13include(__DIR__."/../file/file.inc");
14
15$path = __DIR__ . '/readdir_basic';
16mkdir($path);
17create_files($path, 3);
18
19echo "\n-- Call readdir() with \$path argument --\n";
20var_dump($dh = opendir($path));
21$a = array();
22while( FALSE !== ($file = readdir($dh)) ) {
23    $a[] = $file;
24}
25sort($a);
26foreach($a as $file) {
27    var_dump($file);
28}
29
30echo "\n-- Call readdir() without \$path argument --\n";
31var_dump($dh = opendir($path));
32$a = array();
33while( FALSE !== ( $file = readdir() ) ) {
34    $a[] = $file;
35}
36sort($a);
37foreach($a as $file) {
38    var_dump($file);
39}
40
41delete_files($path, 3);
42closedir($dh);
43?>
44--CLEAN--
45<?php
46$path = __DIR__ . '/readdir_basic';
47rmdir($path);
48?>
49--EXPECTF--
50*** Testing readdir() : basic functionality ***
51
52-- Call readdir() with $path argument --
53resource(%d) of type (stream)
54string(1) "."
55string(2) ".."
56string(9) "file1.tmp"
57string(9) "file2.tmp"
58string(9) "file3.tmp"
59
60-- Call readdir() without $path argument --
61resource(%d) of type (stream)
62string(1) "."
63string(2) ".."
64string(9) "file1.tmp"
65string(9) "file2.tmp"
66string(9) "file3.tmp"
67