Annotation of embedaddon/php/ext/standard/tests/file/basename_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: basename() with various inputs
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') {
6: die('skip non-windows only test');
7: }
8: ?>
9: --FILE--
10: <?php
11:
12: $prefixes = array (
13:
14: // drive letters
15: "A:/",
16: "Z:/",
17: "A:\\",
18:
19: // other prefixes
20: "http://",
21: "blah://",
22: "blah:\\",
23: "hostname:",
24:
25: // home directory ~
26: "~/",
27: "~\\",
28: );
29:
30: $paths = array (
31:
32: "foo",
33: "foo/",
34: "foo\\",
35: "foo.bar",
36: "foo.bar/",
37: "foo.bar\\",
38: "dir/foo.bar",
39: "dir\\foo.bar",
40: "dir with spaces/foo.bar",
41: "dir with spaces\\foo.bar",
42:
43: );
44:
45: foreach ($prefixes as $prefix) {
46: foreach ($paths as $path) {
47: $input = $prefix . $path;
48: echo "basename for path $input is:\n";
49: var_dump(basename($input));
50: }
51: }
52:
53: echo "\ndone\n";
54:
55: ?>
56: --EXPECT--
57: basename for path A:/foo is:
58: string(3) "foo"
59: basename for path A:/foo/ is:
60: string(3) "foo"
61: basename for path A:/foo\ is:
62: string(4) "foo\"
63: basename for path A:/foo.bar is:
64: string(7) "foo.bar"
65: basename for path A:/foo.bar/ is:
66: string(7) "foo.bar"
67: basename for path A:/foo.bar\ is:
68: string(8) "foo.bar\"
69: basename for path A:/dir/foo.bar is:
70: string(7) "foo.bar"
71: basename for path A:/dir\foo.bar is:
72: string(11) "dir\foo.bar"
73: basename for path A:/dir with spaces/foo.bar is:
74: string(7) "foo.bar"
75: basename for path A:/dir with spaces\foo.bar is:
76: string(23) "dir with spaces\foo.bar"
77: basename for path Z:/foo is:
78: string(3) "foo"
79: basename for path Z:/foo/ is:
80: string(3) "foo"
81: basename for path Z:/foo\ is:
82: string(4) "foo\"
83: basename for path Z:/foo.bar is:
84: string(7) "foo.bar"
85: basename for path Z:/foo.bar/ is:
86: string(7) "foo.bar"
87: basename for path Z:/foo.bar\ is:
88: string(8) "foo.bar\"
89: basename for path Z:/dir/foo.bar is:
90: string(7) "foo.bar"
91: basename for path Z:/dir\foo.bar is:
92: string(11) "dir\foo.bar"
93: basename for path Z:/dir with spaces/foo.bar is:
94: string(7) "foo.bar"
95: basename for path Z:/dir with spaces\foo.bar is:
96: string(23) "dir with spaces\foo.bar"
97: basename for path A:\foo is:
98: string(6) "A:\foo"
99: basename for path A:\foo/ is:
100: string(6) "A:\foo"
101: basename for path A:\foo\ is:
102: string(7) "A:\foo\"
103: basename for path A:\foo.bar is:
104: string(10) "A:\foo.bar"
105: basename for path A:\foo.bar/ is:
106: string(10) "A:\foo.bar"
107: basename for path A:\foo.bar\ is:
108: string(11) "A:\foo.bar\"
109: basename for path A:\dir/foo.bar is:
110: string(7) "foo.bar"
111: basename for path A:\dir\foo.bar is:
112: string(14) "A:\dir\foo.bar"
113: basename for path A:\dir with spaces/foo.bar is:
114: string(7) "foo.bar"
115: basename for path A:\dir with spaces\foo.bar is:
116: string(26) "A:\dir with spaces\foo.bar"
117: basename for path http://foo is:
118: string(3) "foo"
119: basename for path http://foo/ is:
120: string(3) "foo"
121: basename for path http://foo\ is:
122: string(4) "foo\"
123: basename for path http://foo.bar is:
124: string(7) "foo.bar"
125: basename for path http://foo.bar/ is:
126: string(7) "foo.bar"
127: basename for path http://foo.bar\ is:
128: string(8) "foo.bar\"
129: basename for path http://dir/foo.bar is:
130: string(7) "foo.bar"
131: basename for path http://dir\foo.bar is:
132: string(11) "dir\foo.bar"
133: basename for path http://dir with spaces/foo.bar is:
134: string(7) "foo.bar"
135: basename for path http://dir with spaces\foo.bar is:
136: string(23) "dir with spaces\foo.bar"
137: basename for path blah://foo is:
138: string(3) "foo"
139: basename for path blah://foo/ is:
140: string(3) "foo"
141: basename for path blah://foo\ is:
142: string(4) "foo\"
143: basename for path blah://foo.bar is:
144: string(7) "foo.bar"
145: basename for path blah://foo.bar/ is:
146: string(7) "foo.bar"
147: basename for path blah://foo.bar\ is:
148: string(8) "foo.bar\"
149: basename for path blah://dir/foo.bar is:
150: string(7) "foo.bar"
151: basename for path blah://dir\foo.bar is:
152: string(11) "dir\foo.bar"
153: basename for path blah://dir with spaces/foo.bar is:
154: string(7) "foo.bar"
155: basename for path blah://dir with spaces\foo.bar is:
156: string(23) "dir with spaces\foo.bar"
157: basename for path blah:\foo is:
158: string(9) "blah:\foo"
159: basename for path blah:\foo/ is:
160: string(9) "blah:\foo"
161: basename for path blah:\foo\ is:
162: string(10) "blah:\foo\"
163: basename for path blah:\foo.bar is:
164: string(13) "blah:\foo.bar"
165: basename for path blah:\foo.bar/ is:
166: string(13) "blah:\foo.bar"
167: basename for path blah:\foo.bar\ is:
168: string(14) "blah:\foo.bar\"
169: basename for path blah:\dir/foo.bar is:
170: string(7) "foo.bar"
171: basename for path blah:\dir\foo.bar is:
172: string(17) "blah:\dir\foo.bar"
173: basename for path blah:\dir with spaces/foo.bar is:
174: string(7) "foo.bar"
175: basename for path blah:\dir with spaces\foo.bar is:
176: string(29) "blah:\dir with spaces\foo.bar"
177: basename for path hostname:foo is:
178: string(12) "hostname:foo"
179: basename for path hostname:foo/ is:
180: string(12) "hostname:foo"
181: basename for path hostname:foo\ is:
182: string(13) "hostname:foo\"
183: basename for path hostname:foo.bar is:
184: string(16) "hostname:foo.bar"
185: basename for path hostname:foo.bar/ is:
186: string(16) "hostname:foo.bar"
187: basename for path hostname:foo.bar\ is:
188: string(17) "hostname:foo.bar\"
189: basename for path hostname:dir/foo.bar is:
190: string(7) "foo.bar"
191: basename for path hostname:dir\foo.bar is:
192: string(20) "hostname:dir\foo.bar"
193: basename for path hostname:dir with spaces/foo.bar is:
194: string(7) "foo.bar"
195: basename for path hostname:dir with spaces\foo.bar is:
196: string(32) "hostname:dir with spaces\foo.bar"
197: basename for path ~/foo is:
198: string(3) "foo"
199: basename for path ~/foo/ is:
200: string(3) "foo"
201: basename for path ~/foo\ is:
202: string(4) "foo\"
203: basename for path ~/foo.bar is:
204: string(7) "foo.bar"
205: basename for path ~/foo.bar/ is:
206: string(7) "foo.bar"
207: basename for path ~/foo.bar\ is:
208: string(8) "foo.bar\"
209: basename for path ~/dir/foo.bar is:
210: string(7) "foo.bar"
211: basename for path ~/dir\foo.bar is:
212: string(11) "dir\foo.bar"
213: basename for path ~/dir with spaces/foo.bar is:
214: string(7) "foo.bar"
215: basename for path ~/dir with spaces\foo.bar is:
216: string(23) "dir with spaces\foo.bar"
217: basename for path ~\foo is:
218: string(5) "~\foo"
219: basename for path ~\foo/ is:
220: string(5) "~\foo"
221: basename for path ~\foo\ is:
222: string(6) "~\foo\"
223: basename for path ~\foo.bar is:
224: string(9) "~\foo.bar"
225: basename for path ~\foo.bar/ is:
226: string(9) "~\foo.bar"
227: basename for path ~\foo.bar\ is:
228: string(10) "~\foo.bar\"
229: basename for path ~\dir/foo.bar is:
230: string(7) "foo.bar"
231: basename for path ~\dir\foo.bar is:
232: string(13) "~\dir\foo.bar"
233: basename for path ~\dir with spaces/foo.bar is:
234: string(7) "foo.bar"
235: basename for path ~\dir with spaces\foo.bar is:
236: string(25) "~\dir with spaces\foo.bar"
237:
238: done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>