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