1--TEST--
2Test scandir() function : usage variations - different relative paths
3--FILE--
4<?php
5/* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
6 * Description: List files & directories inside the specified path
7 * Source code: ext/standard/dir.c
8 */
9
10/*
11 * Test scandir() with relative paths as $dir argument
12 */
13
14echo "*** Testing scandir() : usage variations ***\n";
15
16// include for create_files/delete_files functions
17include (__DIR__ . '/../file/file.inc');
18
19$base_dir_path = __DIR__ . '/scandir_variation4';
20@mkdir($base_dir_path);
21
22$level_one_dir_path = "$base_dir_path/level_one";
23$level_two_dir_path = "$level_one_dir_path/level_two";
24
25// create directories and files
26mkdir($level_one_dir_path);
27create_files($level_one_dir_path, 2, 'numeric', 0755, 1, 'w', 'level_one', 1);
28mkdir($level_two_dir_path);
29create_files($level_two_dir_path, 2, 'numeric', 0755, 1, 'w', 'level_two', 1);
30
31echo "\n-- \$path = './level_one': --\n";
32var_dump(chdir($base_dir_path));
33var_dump(scandir('./level_one'));
34
35echo "\n-- \$path = 'level_one/level_two': --\n";
36var_dump(chdir($base_dir_path));
37var_dump(scandir('level_one/level_two'));
38
39echo "\n-- \$path = '..': --\n";
40var_dump(chdir($level_two_dir_path));
41var_dump(scandir('..'));
42
43echo "\n-- \$path = 'level_two', '.': --\n";
44var_dump(chdir($level_two_dir_path));
45var_dump(scandir('.'));
46
47echo "\n-- \$path = '../': --\n";
48var_dump(chdir($level_two_dir_path));
49var_dump(scandir('../'));
50
51echo "\n-- \$path = './': --\n";
52var_dump(chdir($level_two_dir_path));
53var_dump(scandir('./'));
54
55echo "\n-- \$path = '../../'level_one': --\n";
56var_dump(chdir($level_two_dir_path));
57var_dump(scandir('../../level_one'));
58
59@delete_files($level_one_dir_path, 2, 'level_one');
60@delete_files($level_two_dir_path, 2, 'level_two');
61?>
62===DONE===
63--CLEAN--
64<?php
65$base_dir_path = __DIR__ . '/scandir_variation4';
66rmdir("$base_dir_path/level_one/level_two");
67rmdir("$base_dir_path/level_one");
68rmdir($base_dir_path);
69?>
70--EXPECT--
71*** Testing scandir() : usage variations ***
72
73-- $path = './level_one': --
74bool(true)
75array(5) {
76  [0]=>
77  string(1) "."
78  [1]=>
79  string(2) ".."
80  [2]=>
81  string(14) "level_one1.tmp"
82  [3]=>
83  string(14) "level_one2.tmp"
84  [4]=>
85  string(9) "level_two"
86}
87
88-- $path = 'level_one/level_two': --
89bool(true)
90array(4) {
91  [0]=>
92  string(1) "."
93  [1]=>
94  string(2) ".."
95  [2]=>
96  string(14) "level_two1.tmp"
97  [3]=>
98  string(14) "level_two2.tmp"
99}
100
101-- $path = '..': --
102bool(true)
103array(5) {
104  [0]=>
105  string(1) "."
106  [1]=>
107  string(2) ".."
108  [2]=>
109  string(14) "level_one1.tmp"
110  [3]=>
111  string(14) "level_one2.tmp"
112  [4]=>
113  string(9) "level_two"
114}
115
116-- $path = 'level_two', '.': --
117bool(true)
118array(4) {
119  [0]=>
120  string(1) "."
121  [1]=>
122  string(2) ".."
123  [2]=>
124  string(14) "level_two1.tmp"
125  [3]=>
126  string(14) "level_two2.tmp"
127}
128
129-- $path = '../': --
130bool(true)
131array(5) {
132  [0]=>
133  string(1) "."
134  [1]=>
135  string(2) ".."
136  [2]=>
137  string(14) "level_one1.tmp"
138  [3]=>
139  string(14) "level_one2.tmp"
140  [4]=>
141  string(9) "level_two"
142}
143
144-- $path = './': --
145bool(true)
146array(4) {
147  [0]=>
148  string(1) "."
149  [1]=>
150  string(2) ".."
151  [2]=>
152  string(14) "level_two1.tmp"
153  [3]=>
154  string(14) "level_two2.tmp"
155}
156
157-- $path = '../../'level_one': --
158bool(true)
159array(5) {
160  [0]=>
161  string(1) "."
162  [1]=>
163  string(2) ".."
164  [2]=>
165  string(14) "level_one1.tmp"
166  [3]=>
167  string(14) "level_one2.tmp"
168  [4]=>
169  string(9) "level_two"
170}
171===DONE===
172