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