1--TEST--
2Test dirname() function : basic functionality
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
47function 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
58echo "*** Testing basic operations ***\n";
59check_dirname( $file_paths );
60
61echo "Done\n";
62?>
63--EXPECTREGEX--
64\*\*\* Testing basic operations \*\*\*
65
66--Iteration 1 --
67string\(1\) "."
68
69--Iteration 2 --
70string\(4\) "(\\|\/)foo"
71
72--Iteration 3 --
73string\(3\) "foo"
74
75--Iteration 4 --
76string\(1\) "(\\|\/)"
77
78--Iteration 5 --
79string\(1\) "."
80
81--Iteration 6 --
82string\(1\) "(\\|\/)"
83
84--Iteration 7 --
85string\(4\) "(\\|\/)foo"
86
87--Iteration 8 --
88string\(3\) "foo"
89
90--Iteration 9 --
91string\(1\) "(\\|\/)"
92
93--Iteration 10 --
94string\(4\) "(\\|\/)foo"
95
96--Iteration 11 --
97string\(3\) "foo"
98
99--Iteration 12 --
100string\(1\) "."
101
102--Iteration 13 --
103string\(1\) "."
104
105--Iteration 14 --
106string\(1\) "(\\|\/)"
107
108--Iteration 15 --
109string\(1\) "(\\|\/)"
110
111--Iteration 16 --
112string\(4\) "(\\|\/)foo"
113
114--Iteration 17 --
115string\(3\) "foo"
116
117--Iteration 18 --
118string\(1\) "(\\|\/)"
119
120--Iteration 19 --
121string\(1\) "(\\|\/)"
122
123--Iteration 20 --
124string\(1\) "."
125
126--Iteration 21 --
127string\(4\) "(\\|\/)foo"
128
129--Iteration 22 --
130string\(1\) "."
131
132--Iteration 23 --
133string\(4\) "(\\|\/)foo"
134
135--Iteration 24 --
136string\(3\) "foo"
137
138--Iteration 25 --
139string\(1\) "."
140
141--Iteration 26 --
142string\(1\) "(\\|\/)"
143
144--Iteration 27 --
145string\(1\) "(\\|\/)"
146
147--Iteration 28 --
148string\(1\) "."
149
150--Iteration 29 --
151string\(8\) "(\\|\/)foo\x00bar"
152Done
153