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 Not 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(1) "."
51string(10) "c:\..\dir1"
52string(5) "\dir1"
53string(4) "c:\."
54array(4) {
55  ["dirname"]=>
56  string(1) "."
57  ["basename"]=>
58  string(10) "c:\..\dir1"
59  ["extension"]=>
60  string(5) "\dir1"
61  ["filename"]=>
62  string(4) "c:\."
63}
64-- Iteration 2 --
65string(1) "."
66string(33) "c:\test\..\test2\.\adir\afile.txt"
67string(3) "txt"
68string(29) "c:\test\..\test2\.\adir\afile"
69array(4) {
70  ["dirname"]=>
71  string(1) "."
72  ["basename"]=>
73  string(33) "c:\test\..\test2\.\adir\afile.txt"
74  ["extension"]=>
75  string(3) "txt"
76  ["filename"]=>
77  string(29) "c:\test\..\test2\.\adir\afile"
78}
79-- Iteration 3 --
80string(22) "/usr/include/../arpa/."
81string(6) "inet.h"
82string(1) "h"
83string(4) "inet"
84array(4) {
85  ["dirname"]=>
86  string(22) "/usr/include/../arpa/."
87  ["basename"]=>
88  string(6) "inet.h"
89  ["extension"]=>
90  string(1) "h"
91  ["filename"]=>
92  string(4) "inet"
93}
94-- Iteration 4 --
95string(1) "."
96string(23) "c:\test\adir\afile..txt"
97string(3) "txt"
98string(19) "c:\test\adir\afile."
99array(4) {
100  ["dirname"]=>
101  string(1) "."
102  ["basename"]=>
103  string(23) "c:\test\adir\afile..txt"
104  ["extension"]=>
105  string(3) "txt"
106  ["filename"]=>
107  string(19) "c:\test\adir\afile."
108}
109-- Iteration 5 --
110string(17) "/usr/include/arpa"
111string(7) "inet..h"
112string(1) "h"
113string(5) "inet."
114array(4) {
115  ["dirname"]=>
116  string(17) "/usr/include/arpa"
117  ["basename"]=>
118  string(7) "inet..h"
119  ["extension"]=>
120  string(1) "h"
121  ["filename"]=>
122  string(5) "inet."
123}
124-- Iteration 6 --
125string(1) "."
126string(19) "c:\test\adir\afile."
127string(0) ""
128string(18) "c:\test\adir\afile"
129array(4) {
130  ["dirname"]=>
131  string(1) "."
132  ["basename"]=>
133  string(19) "c:\test\adir\afile."
134  ["extension"]=>
135  string(0) ""
136  ["filename"]=>
137  string(18) "c:\test\adir\afile"
138}
139-- Iteration 7 --
140string(17) "/usr/include/arpa"
141string(5) "inet."
142string(0) ""
143string(4) "inet"
144array(4) {
145  ["dirname"]=>
146  string(17) "/usr/include/arpa"
147  ["basename"]=>
148  string(5) "inet."
149  ["extension"]=>
150  string(0) ""
151  ["filename"]=>
152  string(4) "inet"
153}
154-- Iteration 8 --
155string(17) "/usr/include/arpa"
156string(6) "inet,h"
157string(0) ""
158string(6) "inet,h"
159array(3) {
160  ["dirname"]=>
161  string(17) "/usr/include/arpa"
162  ["basename"]=>
163  string(6) "inet,h"
164  ["filename"]=>
165  string(6) "inet,h"
166}
167-- Iteration 9 --
168string(1) "."
169string(11) "c:afile.txt"
170string(3) "txt"
171string(7) "c:afile"
172array(4) {
173  ["dirname"]=>
174  string(1) "."
175  ["basename"]=>
176  string(11) "c:afile.txt"
177  ["extension"]=>
178  string(3) "txt"
179  ["filename"]=>
180  string(7) "c:afile"
181}
182-- Iteration 10 --
183string(1) "."
184string(22) "..\.\..\test\afile.txt"
185string(3) "txt"
186string(18) "..\.\..\test\afile"
187array(4) {
188  ["dirname"]=>
189  string(1) "."
190  ["basename"]=>
191  string(22) "..\.\..\test\afile.txt"
192  ["extension"]=>
193  string(3) "txt"
194  ["filename"]=>
195  string(18) "..\.\..\test\afile"
196}
197-- Iteration 11 --
198string(12) ".././../test"
199string(5) "afile"
200string(0) ""
201string(5) "afile"
202array(3) {
203  ["dirname"]=>
204  string(12) ".././../test"
205  ["basename"]=>
206  string(5) "afile"
207  ["filename"]=>
208  string(5) "afile"
209}
210-- Iteration 12 --
211string(1) "."
212string(1) "."
213string(0) ""
214string(0) ""
215array(4) {
216  ["dirname"]=>
217  string(1) "."
218  ["basename"]=>
219  string(1) "."
220  ["extension"]=>
221  string(0) ""
222  ["filename"]=>
223  string(0) ""
224}
225-- Iteration 13 --
226string(1) "."
227string(2) ".."
228string(0) ""
229string(1) "."
230array(4) {
231  ["dirname"]=>
232  string(1) "."
233  ["basename"]=>
234  string(2) ".."
235  ["extension"]=>
236  string(0) ""
237  ["filename"]=>
238  string(1) "."
239}
240-- Iteration 14 --
241string(1) "."
242string(3) "..."
243string(0) ""
244string(2) ".."
245array(4) {
246  ["dirname"]=>
247  string(1) "."
248  ["basename"]=>
249  string(3) "..."
250  ["extension"]=>
251  string(0) ""
252  ["filename"]=>
253  string(2) ".."
254}
255-- Iteration 15 --
256string(12) "/usr/lib/..."
257string(5) "afile"
258string(0) ""
259string(5) "afile"
260array(3) {
261  ["dirname"]=>
262  string(12) "/usr/lib/..."
263  ["basename"]=>
264  string(5) "afile"
265  ["filename"]=>
266  string(5) "afile"
267}
268Done
269