Annotation of embedaddon/php/ext/standard/tests/dir/dir_variation9-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test dir() function : usage variations - relative valid and invalid paths
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) != 'WIN') {
6: die("skip Valid only on Windows");
7: }
8: ?>
9: --FILE--
10: <?php
11: /*
12: * Prototype : object dir(string $directory[, resource $context])
13: * Description: Directory class with properties, handle and class and methods read, rewind and close
14: * Source code: ext/standard/dir.c
15: */
16:
17: /*
18: * Checking the behavior of dir() function by passing directories which
19: * have valid and invalid relative path.
20: */
21:
22: echo "*** Testing dir() : checking with valid and invalid paths ***\n";
23:
24: /* create the temporary directories */
25:
26: $file_path = dirname(__FILE__);
27:
28: // directory dir_variation91 with one sub-directory sub_dir11 and sub-sub-directory sub_dir111
29: $dir_path1 = $file_path."/dir_variation91";
30: $sub_dir11 = $dir_path1."/sub_dir11";
31: $sub_dir111 = $sub_dir11."/sub_dir111";
32:
33: // directory dir_variation92 with one sub-directory sub_dir21
34: $dir_path2 = $file_path."/dir_variation92";
35: $sub_dir21 = $dir_path2."/sub_dir21";
36:
37: @mkdir($dir_path1);
38: @mkdir($dir_path2);
39: @mkdir($sub_dir11);
40: @mkdir($sub_dir111);
41: @mkdir($sub_dir21);
42:
43: // open the directory with valid paths
44: echo "\n-- With valid paths --\n";
45: var_dump( dir("$dir_path1/sub_dir11/sub_dir111/..") );
46: var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91") );
47: var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir11/..") );
48: var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/..") );
49:
50: // open the directory with invalid path
51: echo "\n-- With invalid paths --\n";
52: var_dump( dir("$dir_path1/sub_dir12/sub_dir111/..") );
53: var_dump( dir("$dir_path2/sub_dir21/../dir_variation91") );
54: var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir12/..") );
55: var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..") );
56:
57: echo "Done";
58: ?>
59: --CLEAN--
60: <?php
61: $file_path = dirname(__FILE__);
62:
63: $dir_path1 = $file_path."/dir_variation91";
64: $sub_dir11 = $dir_path1."/sub_dir11";
65: $sub_dir111 = $sub_dir11."/sub_dir111";
66: $dir_path2 = $file_path."/dir_variation92";
67: $sub_dir21 = $dir_path2."/sub_dir21";
68:
69: rmdir($sub_dir21);
70: rmdir($sub_dir111);
71: rmdir($sub_dir11);
72: rmdir($dir_path1);
73: rmdir($dir_path2);
74: ?>
75: --EXPECTF--
76: *** Testing dir() : checking with valid and invalid paths ***
77:
78: -- With valid paths --
79: object(Directory)#%d (2) {
80: ["path"]=>
81: string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/.."
82: ["handle"]=>
83: resource(%d) of type (stream)
84: }
85: object(Directory)#%d (2) {
86: ["path"]=>
87: string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91"
88: ["handle"]=>
89: resource(%d) of type (stream)
90: }
91: object(Directory)#%d (2) {
92: ["path"]=>
93: string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir11/.."
94: ["handle"]=>
95: resource(%d) of type (stream)
96: }
97: object(Directory)#%d (2) {
98: ["path"]=>
99: string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/.."
100: ["handle"]=>
101: resource(%d) of type (stream)
102: }
103:
104: -- With invalid paths --
105:
106: Warning: dir(%sdir_variation91/sub_dir12/sub_dir111/..,%sdir_variation91/sub_dir12/sub_dir111/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d
107:
108: Warning: dir(%s/dir_variation91/sub_dir12/sub_dir111/..): failed to open dir: %s in %s on line %d
109: bool(false)
110:
111: Warning: dir(%sdir_variation92/sub_dir21/../dir_variation91,%sdir_variation92/sub_dir21/../dir_variation91): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d
112:
113: Warning: dir(%s/dir_variation92/sub_dir21/../dir_variation91): failed to open dir: %s in %s on line %d
114: bool(false)
115:
116: Warning: dir(%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..,%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d
117:
118: Warning: dir(%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): failed to open dir: %s in %s on line %d
119: bool(false)
120:
121: Warning: dir(%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..,%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d
122:
123: Warning: dir(%s/dir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): failed to open dir: %s in %s on line %d
124: bool(false)
125: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>