Annotation of embedaddon/php/ext/standard/tests/strings/dirname_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test dirname() function : basic funtionality
3: --FILE--
4: <?php
5: /* Prototype: string dirname ( string $path );
6: Description: Returns directory name component of path.
7: */
8: $file_paths = array (
9: /* simple paths */
10: "bar",
11: "/foo/bar",
12: "foo/bar",
13: "/bar",
14: "bar/",
15: "/bar/",
16: "/foo/bar/",
17: "foo/bar/",
18: "/bar/",
19:
20: /* path with only files and trailing slashes*/
21: "/foo/bar.gz",
22: "foo/bar.gz",
23: "bar.gz",
24: "bar.gz/",
25: "/bar.gz",
26: "/bar.gz/",
27: "/foo/bar.gz/",
28: "foo/bar.gz/",
29: "/bar.gz/",
30:
31: /* path with file extension and trailing slashes */
32: "/.gz",
33: ".gz",
34: "/foo/.gz",
35: ".gz/",
36: "/foo/.gz/",
37: "foo/.gz/",
38:
39: /* paths with binary value to check if the function is binary safe*/
40: "foo".chr(0)."bar",
41: "/foo".chr(0)."bar/",
42: "/foo".chr(0)."bar",
43: "foo".chr(0)."bar/",
44: "/foo".chr(0)."bar/t.gz"
45: );
46:
47: function check_dirname( $paths ) {
48: $loop_counter = 0;
49: $noOfPaths = count($paths);
50: for( ; $loop_counter < $noOfPaths; $loop_counter++ ) {
51: echo "\n--Iteration ";
52: echo $loop_counter + 1;
53: echo " --\n";
54: var_dump( dirname($paths[$loop_counter]) );
55: }
56: }
57:
58: echo "*** Testing basic operations ***\n";
59: check_dirname( $file_paths );
60:
61: echo "Done\n";
62: ?>
63:
64: --EXPECTREGEX--
65: \*\*\* Testing basic operations \*\*\*
66:
67: --Iteration 1 --
68: string\(1\) "."
69:
70: --Iteration 2 --
71: string\(4\) "(\\|\/)foo"
72:
73: --Iteration 3 --
74: string\(3\) "foo"
75:
76: --Iteration 4 --
77: string\(1\) "(\\|\/)"
78:
79: --Iteration 5 --
80: string\(1\) "."
81:
82: --Iteration 6 --
83: string\(1\) "(\\|\/)"
84:
85: --Iteration 7 --
86: string\(4\) "(\\|\/)foo"
87:
88: --Iteration 8 --
89: string\(3\) "foo"
90:
91: --Iteration 9 --
92: string\(1\) "(\\|\/)"
93:
94: --Iteration 10 --
95: string\(4\) "(\\|\/)foo"
96:
97: --Iteration 11 --
98: string\(3\) "foo"
99:
100: --Iteration 12 --
101: string\(1\) "."
102:
103: --Iteration 13 --
104: string\(1\) "."
105:
106: --Iteration 14 --
107: string\(1\) "(\\|\/)"
108:
109: --Iteration 15 --
110: string\(1\) "(\\|\/)"
111:
112: --Iteration 16 --
113: string\(4\) "(\\|\/)foo"
114:
115: --Iteration 17 --
116: string\(3\) "foo"
117:
118: --Iteration 18 --
119: string\(1\) "(\\|\/)"
120:
121: --Iteration 19 --
122: string\(1\) "(\\|\/)"
123:
124: --Iteration 20 --
125: string\(1\) "."
126:
127: --Iteration 21 --
128: string\(4\) "(\\|\/)foo"
129:
130: --Iteration 22 --
131: string\(1\) "."
132:
133: --Iteration 23 --
134: string\(4\) "(\\|\/)foo"
135:
136: --Iteration 24 --
137: string\(3\) "foo"
138:
139: --Iteration 25 --
140: string\(1\) "."
141:
142: --Iteration 26 --
143: string\(1\) "(\\|\/)"
144:
145: --Iteration 27 --
146: string\(1\) "(\\|\/)"
147:
148: --Iteration 28 --
149: string\(1\) "."
150:
151: --Iteration 29 --
152: string\(8\) "(\\|\/)foo\x00bar"
153: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>