Annotation of embedaddon/php/ext/standard/tests/dir/opendir_variation4.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test opendir() function : usage variations - different relative paths
3: --FILE--
4: <?php
5: /* Prototype : mixed opendir(string $path[, resource $context])
6: * Description: Open a directory and return a dir_handle
7: * Source code: ext/standard/dir.c
8: */
9:
10: /*
11: * Test opendir() with different relative paths as $path argument
12: */
13:
14: echo "*** Testing opendir() : usage variation ***\n";
15:
16: $base_dir_path = dirname(__FILE__);
17:
18: $level_one_dir_name = "level_one";
19: $level_one_dir_path = "$base_dir_path/$level_one_dir_name";
20:
21: $level_two_dir_name = "level_two";
22: $level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
23:
24: // create directories
25: mkdir($level_one_dir_path);
26: mkdir($level_two_dir_path);
27:
28: echo "\n-- \$path = './level_one': --\n";
29: var_dump(chdir($base_dir_path));
30: var_dump($dh = opendir("./$level_one_dir_name"));
31: clean_dh($dh);
32:
33: echo "\n-- \$path = 'level_one/level_two': --\n";
34: var_dump(chdir($base_dir_path));
35: var_dump($dh = opendir("$level_one_dir_name/$level_two_dir_name"));
36: clean_dh($dh);
37:
38: echo "\n-- \$path = '..': --\n";
39: var_dump($dh = opendir('..'));
40: clean_dh($dh);
41:
42: echo "\n-- \$path = 'level_two', '.': --\n";
43: var_dump(chdir($level_two_dir_path));
44: var_dump($dh = opendir('.'));
45: clean_dh($dh);
46:
47: echo "\n-- \$path = '../': --\n";
48: var_dump($dh = opendir('../'));
49: clean_dh($dh);
50:
51: echo "\n-- \$path = './': --\n";
52: var_dump(chdir($level_two_dir_path));
53: var_dump($dh = opendir('./'));
54: clean_dh($dh);
55:
56: echo "\n-- \$path = '../../'level_one': --\n";
57: var_dump(chdir($level_two_dir_path));
58: var_dump($dh = opendir("../../$level_one_dir_name"));
59: clean_dh($dh);
60:
61: /*
62: * function to remove directory handle before re-using variable name in test
63: * and to ensure directory is not in use at CLEAN section so can me removed
64: */
65: function clean_dh($dh){
66: if (is_resource($dh)) {
67: closedir($dh);
68: }
69: unset($dh);
70: }
71: ?>
72: ===DONE===
73: --CLEAN--
74: <?php
75: $file_path = dirname(__FILE__);
76: rmdir("$file_path/level_one/level_two");
77: rmdir("$file_path/level_one");
78: ?>
79: --EXPECTF--
80: *** Testing opendir() : usage variation ***
81:
82: -- $path = './level_one': --
83: bool(true)
84: resource(%d) of type (stream)
85:
86: -- $path = 'level_one/level_two': --
87: bool(true)
88: resource(%d) of type (stream)
89:
90: -- $path = '..': --
91: resource(%d) of type (stream)
92:
93: -- $path = 'level_two', '.': --
94: bool(true)
95: resource(%d) of type (stream)
96:
97: -- $path = '../': --
98: resource(%d) of type (stream)
99:
100: -- $path = './': --
101: bool(true)
102: resource(%d) of type (stream)
103:
104: -- $path = '../../'level_one': --
105: bool(true)
106: resource(%d) of type (stream)
107: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>