Annotation of embedaddon/php/ext/standard/tests/file/pathinfo_basic2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test pathinfo() function: basic functionality
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --SKIPIF--
6: <?php
7: if(substr(PHP_OS, 0, 3) == "WIN")
8: die("skip Not valid for Windows");
9: ?>
10: --FILE--
11: <?php
12: /* Prototype: mixed pathinfo ( string $path [, int $options] );
13: Description: Returns information about a file path
14: */
15:
16: echo "*** Testing basic functions of pathinfo() ***\n";
17:
18: $paths = array (
19: 'c:\..\dir1',
20: 'c:\test\..\test2\.\adir\afile.txt',
21: '/usr/include/../arpa/./inet.h',
22: 'c:\test\adir\afile..txt',
23: '/usr/include/arpa/inet..h',
24: 'c:\test\adir\afile.',
25: '/usr/include/arpa/inet.',
26: '/usr/include/arpa/inet,h',
27: 'c:afile.txt',
28: '..\.\..\test\afile.txt',
29: '.././../test/afile',
30: '.',
31: '..',
32: '...',
33: '/usr/lib/.../afile'
34:
35: );
36:
37: $counter = 1;
38: /* loop through $paths to test each $path in the above array */
39: foreach($paths as $path) {
40: echo "-- Iteration $counter --\n";
41: var_dump( pathinfo($path, PATHINFO_DIRNAME) );
42: var_dump( pathinfo($path, PATHINFO_BASENAME) );
43: var_dump( pathinfo($path, PATHINFO_EXTENSION) );
44: var_dump( pathinfo($path, PATHINFO_FILENAME) );
45: var_dump( pathinfo($path) );
46: $counter++;
47: }
48:
49: echo "Done\n";
50: ?>
51: --EXPECTF--
52: *** Testing basic functions of pathinfo() ***
53: -- Iteration 1 --
54: %unicode|string%(1) "."
55: %unicode|string%(10) "c:\..\dir1"
56: %unicode|string%(5) "\dir1"
57: %unicode|string%(4) "c:\."
58: array(4) {
59: [%u|b%"dirname"]=>
60: %unicode|string%(1) "."
61: [%u|b%"basename"]=>
62: %unicode|string%(10) "c:\..\dir1"
63: [%u|b%"extension"]=>
64: %unicode|string%(5) "\dir1"
65: [%u|b%"filename"]=>
66: %unicode|string%(4) "c:\."
67: }
68: -- Iteration 2 --
69: %unicode|string%(1) "."
70: %unicode|string%(33) "c:\test\..\test2\.\adir\afile.txt"
71: %unicode|string%(3) "txt"
72: %unicode|string%(29) "c:\test\..\test2\.\adir\afile"
73: array(4) {
74: [%u|b%"dirname"]=>
75: %unicode|string%(1) "."
76: [%u|b%"basename"]=>
77: %unicode|string%(33) "c:\test\..\test2\.\adir\afile.txt"
78: [%u|b%"extension"]=>
79: %unicode|string%(3) "txt"
80: [%u|b%"filename"]=>
81: %unicode|string%(29) "c:\test\..\test2\.\adir\afile"
82: }
83: -- Iteration 3 --
84: %unicode|string%(22) "/usr/include/../arpa/."
85: %unicode|string%(6) "inet.h"
86: %unicode|string%(1) "h"
87: %unicode|string%(4) "inet"
88: array(4) {
89: [%u|b%"dirname"]=>
90: %unicode|string%(22) "/usr/include/../arpa/."
91: [%u|b%"basename"]=>
92: %unicode|string%(6) "inet.h"
93: [%u|b%"extension"]=>
94: %unicode|string%(1) "h"
95: [%u|b%"filename"]=>
96: %unicode|string%(4) "inet"
97: }
98: -- Iteration 4 --
99: %unicode|string%(1) "."
100: %unicode|string%(23) "c:\test\adir\afile..txt"
101: %unicode|string%(3) "txt"
102: %unicode|string%(19) "c:\test\adir\afile."
103: array(4) {
104: [%u|b%"dirname"]=>
105: %unicode|string%(1) "."
106: [%u|b%"basename"]=>
107: %unicode|string%(23) "c:\test\adir\afile..txt"
108: [%u|b%"extension"]=>
109: %unicode|string%(3) "txt"
110: [%u|b%"filename"]=>
111: %unicode|string%(19) "c:\test\adir\afile."
112: }
113: -- Iteration 5 --
114: %unicode|string%(17) "/usr/include/arpa"
115: %unicode|string%(7) "inet..h"
116: %unicode|string%(1) "h"
117: %unicode|string%(5) "inet."
118: array(4) {
119: [%u|b%"dirname"]=>
120: %unicode|string%(17) "/usr/include/arpa"
121: [%u|b%"basename"]=>
122: %unicode|string%(7) "inet..h"
123: [%u|b%"extension"]=>
124: %unicode|string%(1) "h"
125: [%u|b%"filename"]=>
126: %unicode|string%(5) "inet."
127: }
128: -- Iteration 6 --
129: %unicode|string%(1) "."
130: %unicode|string%(19) "c:\test\adir\afile."
131: %unicode|string%(0) ""
132: %unicode|string%(18) "c:\test\adir\afile"
133: array(4) {
134: [%u|b%"dirname"]=>
135: %unicode|string%(1) "."
136: [%u|b%"basename"]=>
137: %unicode|string%(19) "c:\test\adir\afile."
138: [%u|b%"extension"]=>
139: %unicode|string%(0) ""
140: [%u|b%"filename"]=>
141: %unicode|string%(18) "c:\test\adir\afile"
142: }
143: -- Iteration 7 --
144: %unicode|string%(17) "/usr/include/arpa"
145: %unicode|string%(5) "inet."
146: %unicode|string%(0) ""
147: %unicode|string%(4) "inet"
148: array(4) {
149: [%u|b%"dirname"]=>
150: %unicode|string%(17) "/usr/include/arpa"
151: [%u|b%"basename"]=>
152: %unicode|string%(5) "inet."
153: [%u|b%"extension"]=>
154: %unicode|string%(0) ""
155: [%u|b%"filename"]=>
156: %unicode|string%(4) "inet"
157: }
158: -- Iteration 8 --
159: %unicode|string%(17) "/usr/include/arpa"
160: %unicode|string%(6) "inet,h"
161: %unicode|string%(0) ""
162: %unicode|string%(6) "inet,h"
163: array(3) {
164: [%u|b%"dirname"]=>
165: %unicode|string%(17) "/usr/include/arpa"
166: [%u|b%"basename"]=>
167: %unicode|string%(6) "inet,h"
168: [%u|b%"filename"]=>
169: %unicode|string%(6) "inet,h"
170: }
171: -- Iteration 9 --
172: %unicode|string%(1) "."
173: %unicode|string%(11) "c:afile.txt"
174: %unicode|string%(3) "txt"
175: %unicode|string%(7) "c:afile"
176: array(4) {
177: [%u|b%"dirname"]=>
178: %unicode|string%(1) "."
179: [%u|b%"basename"]=>
180: %unicode|string%(11) "c:afile.txt"
181: [%u|b%"extension"]=>
182: %unicode|string%(3) "txt"
183: [%u|b%"filename"]=>
184: %unicode|string%(7) "c:afile"
185: }
186: -- Iteration 10 --
187: %unicode|string%(1) "."
188: %unicode|string%(22) "..\.\..\test\afile.txt"
189: %unicode|string%(3) "txt"
190: %unicode|string%(18) "..\.\..\test\afile"
191: array(4) {
192: [%u|b%"dirname"]=>
193: %unicode|string%(1) "."
194: [%u|b%"basename"]=>
195: %unicode|string%(22) "..\.\..\test\afile.txt"
196: [%u|b%"extension"]=>
197: %unicode|string%(3) "txt"
198: [%u|b%"filename"]=>
199: %unicode|string%(18) "..\.\..\test\afile"
200: }
201: -- Iteration 11 --
202: %unicode|string%(12) ".././../test"
203: %unicode|string%(5) "afile"
204: %unicode|string%(0) ""
205: %unicode|string%(5) "afile"
206: array(3) {
207: [%u|b%"dirname"]=>
208: %unicode|string%(12) ".././../test"
209: [%u|b%"basename"]=>
210: %unicode|string%(5) "afile"
211: [%u|b%"filename"]=>
212: %unicode|string%(5) "afile"
213: }
214: -- Iteration 12 --
215: %unicode|string%(1) "."
216: %unicode|string%(1) "."
217: %unicode|string%(0) ""
218: %unicode|string%(0) ""
219: array(4) {
220: [%u|b%"dirname"]=>
221: %unicode|string%(1) "."
222: [%u|b%"basename"]=>
223: %unicode|string%(1) "."
224: [%u|b%"extension"]=>
225: %unicode|string%(0) ""
226: [%u|b%"filename"]=>
227: %unicode|string%(0) ""
228: }
229: -- Iteration 13 --
230: %unicode|string%(1) "."
231: %unicode|string%(2) ".."
232: %unicode|string%(0) ""
233: %unicode|string%(1) "."
234: array(4) {
235: [%u|b%"dirname"]=>
236: %unicode|string%(1) "."
237: [%u|b%"basename"]=>
238: %unicode|string%(2) ".."
239: [%u|b%"extension"]=>
240: %unicode|string%(0) ""
241: [%u|b%"filename"]=>
242: %unicode|string%(1) "."
243: }
244: -- Iteration 14 --
245: %unicode|string%(1) "."
246: %unicode|string%(3) "..."
247: %unicode|string%(0) ""
248: %unicode|string%(2) ".."
249: array(4) {
250: [%u|b%"dirname"]=>
251: %unicode|string%(1) "."
252: [%u|b%"basename"]=>
253: %unicode|string%(3) "..."
254: [%u|b%"extension"]=>
255: %unicode|string%(0) ""
256: [%u|b%"filename"]=>
257: %unicode|string%(2) ".."
258: }
259: -- Iteration 15 --
260: %unicode|string%(12) "/usr/lib/..."
261: %unicode|string%(5) "afile"
262: %unicode|string%(0) ""
263: %unicode|string%(5) "afile"
264: array(3) {
265: [%u|b%"dirname"]=>
266: %unicode|string%(12) "/usr/lib/..."
267: [%u|b%"basename"]=>
268: %unicode|string%(5) "afile"
269: [%u|b%"filename"]=>
270: %unicode|string%(5) "afile"
271: }
272: Done
273:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>