1--TEST--
2Test dirname() function : usage variations
3--FILE--
4<?php
5class temp
6{
7   function __toString() {
8     return "Object";
9   }
10}
11
12$file_path_variations = array (
13  /* home dir shortcut char */
14  "~/home/user/bar",
15  "~/home/user/bar/",
16  "~/home/user/bar.tar",
17  "~/home/user/bar.tar/",
18
19  /* with hotname:dir notation */
20  "hostname:/home/user/bar.tar",
21  "hostname:/home/user/tbar.gz/",
22  "hostname:/home/user/My Pics.gz",
23  "hostname:/home/user/My Pics.gz/",
24  "hostname:/home/user/My Pics/",
25  "hostname:/home/user/My Pics",
26
27  /* path containing numeric string */
28  "10.5",
29  "/10.5",
30  "/10.5/",
31  "10.5/",
32  "10/10.gz",
33  '0',
34  "0",
35
36  /* object */
37  new temp,
38
39  /* path as spaces */
40  " ",
41  ' ',
42
43  /* empty path */
44  "",
45  '',
46);
47
48function check_dirname( $paths ) {
49   $loop_counter = 0;
50   $noOfPaths = count($paths);
51   for( ; $loop_counter < $noOfPaths; $loop_counter++ ) {
52     echo "\n--Iteration ";
53     echo $loop_counter +1;
54     echo " --\n";
55     var_dump( dirname($paths[$loop_counter]) );
56   }
57}
58
59echo "*** Testing possible variations in path ***\n";
60check_dirname( $file_path_variations );
61
62echo "Done\n";
63?>
64--EXPECTREGEX--
65\*\*\* Testing possible variations in path \*\*\*
66
67--Iteration 1 --
68string\(11\) "~(\\|\/)home(\\|\/)user"
69
70--Iteration 2 --
71string\(11\) "~(\\|\/)home(\\|\/)user"
72
73--Iteration 3 --
74string\(11\) "~(\\|\/)home(\\|\/)user"
75
76--Iteration 4 --
77string\(11\) "~(\\|\/)home(\\|\/)user"
78
79--Iteration 5 --
80string\(19\) "hostname:(\\|\/)home(\\|\/)user"
81
82--Iteration 6 --
83string\(19\) "hostname:(\\|\/)home(\\|\/)user"
84
85--Iteration 7 --
86string\(19\) "hostname:(\\|\/)home(\\|\/)user"
87
88--Iteration 8 --
89string\(19\) "hostname:(\\|\/)home(\\|\/)user"
90
91--Iteration 9 --
92string\(19\) "hostname:(\\|\/)home(\\|\/)user"
93
94--Iteration 10 --
95string\(19\) "hostname:(\\|\/)home(\\|\/)user"
96
97--Iteration 11 --
98string\(1\) "."
99
100--Iteration 12 --
101string\(1\) "(\\|\/)"
102
103--Iteration 13 --
104string\(1\) "(\\|\/)"
105
106--Iteration 14 --
107string\(1\) "."
108
109--Iteration 15 --
110string\(2\) "10"
111
112--Iteration 16 --
113string\(1\) "."
114
115--Iteration 17 --
116string\(1\) "."
117
118--Iteration 18 --
119string\(1\) "."
120
121--Iteration 19 --
122string\(1\) "."
123
124--Iteration 20 --
125string\(1\) "."
126
127--Iteration 21 --
128string\(0\) ""
129
130--Iteration 22 --
131string\(0\) ""
132Done
133