1--TEST--
2Test readdir() function : usage variations - sub-directories
3--FILE--
4<?php
5/* Prototype  : string readdir([resource $dir_handle])
6 * Description: Read directory entry from dir_handle
7 * Source code: ext/standard/dir.c
8 */
9
10/*
11 * Pass a directory handle pointing to a directory that has a sub-directory
12 * to test behaviour of readdir()
13 */
14
15echo "*** Testing readdir() : usage variations ***\n";
16
17// include the file.inc for Function: function create_files()
18chdir(dirname(__FILE__));
19include(dirname(__FILE__)."/../file/file.inc");
20
21$path_top = dirname(__FILE__) . '/readdir_variation3';
22$path_sub = $path_top . '/sub_folder';
23mkdir($path_top);
24mkdir($path_sub);
25
26create_files($path_top, 2);
27create_files($path_sub, 2);
28
29$dir_handle = opendir($path_top);
30while(FALSE !== ($file = readdir($dir_handle))) {
31
32	// different OS order files differently so will
33	// store file names into an array so can use sorted in expected output
34	$contents[] = $file;
35}
36
37// more important to check that all contents are present than order they are returned in
38sort($contents);
39var_dump($contents);
40
41delete_files($path_top, 2);
42delete_files($path_sub, 2);
43
44closedir($dir_handle);
45?>
46===DONE===
47--CLEAN--
48<?php
49$path_top = dirname(__FILE__) . '/readdir_variation3';
50$path_sub = $path_top . '/sub_folder';
51rmdir($path_sub);
52rmdir($path_top);
53?>
54--EXPECT--
55*** Testing readdir() : usage variations ***
56array(5) {
57  [0]=>
58  string(1) "."
59  [1]=>
60  string(2) ".."
61  [2]=>
62  string(9) "file1.tmp"
63  [3]=>
64  string(9) "file2.tmp"
65  [4]=>
66  string(10) "sub_folder"
67}
68===DONE===
69