1--TEST-- 2Test dirname() function : basic functionality 3--FILE-- 4<?php 5$file_paths = array ( 6 /* simple paths */ 7 "bar", 8 "/foo/bar", 9 "foo/bar", 10 "/bar", 11 "bar/", 12 "/bar/", 13 "/foo/bar/", 14 "foo/bar/", 15 "/bar/", 16 17 /* path with only files and trailing slashes*/ 18 "/foo/bar.gz", 19 "foo/bar.gz", 20 "bar.gz", 21 "bar.gz/", 22 "/bar.gz", 23 "/bar.gz/", 24 "/foo/bar.gz/", 25 "foo/bar.gz/", 26 "/bar.gz/", 27 28 /* path with file extension and trailing slashes */ 29 "/.gz", 30 ".gz", 31 "/foo/.gz", 32 ".gz/", 33 "/foo/.gz/", 34 "foo/.gz/", 35 36 /* paths with binary value to check if the function is binary safe*/ 37 "foo".chr(0)."bar", 38 "/foo".chr(0)."bar/", 39 "/foo".chr(0)."bar", 40 "foo".chr(0)."bar/", 41 "/foo".chr(0)."bar/t.gz" 42); 43 44function check_dirname( $paths ) { 45 $loop_counter = 0; 46 $noOfPaths = count($paths); 47 for( ; $loop_counter < $noOfPaths; $loop_counter++ ) { 48 echo "\n--Iteration "; 49 echo $loop_counter + 1; 50 echo " --\n"; 51 var_dump( dirname($paths[$loop_counter]) ); 52 } 53} 54 55echo "*** Testing basic operations ***\n"; 56check_dirname( $file_paths ); 57 58echo "Done\n"; 59?> 60--EXPECTREGEX-- 61\*\*\* Testing basic operations \*\*\* 62 63--Iteration 1 -- 64string\(1\) "." 65 66--Iteration 2 -- 67string\(4\) "(\\|\/)foo" 68 69--Iteration 3 -- 70string\(3\) "foo" 71 72--Iteration 4 -- 73string\(1\) "(\\|\/)" 74 75--Iteration 5 -- 76string\(1\) "." 77 78--Iteration 6 -- 79string\(1\) "(\\|\/)" 80 81--Iteration 7 -- 82string\(4\) "(\\|\/)foo" 83 84--Iteration 8 -- 85string\(3\) "foo" 86 87--Iteration 9 -- 88string\(1\) "(\\|\/)" 89 90--Iteration 10 -- 91string\(4\) "(\\|\/)foo" 92 93--Iteration 11 -- 94string\(3\) "foo" 95 96--Iteration 12 -- 97string\(1\) "." 98 99--Iteration 13 -- 100string\(1\) "." 101 102--Iteration 14 -- 103string\(1\) "(\\|\/)" 104 105--Iteration 15 -- 106string\(1\) "(\\|\/)" 107 108--Iteration 16 -- 109string\(4\) "(\\|\/)foo" 110 111--Iteration 17 -- 112string\(3\) "foo" 113 114--Iteration 18 -- 115string\(1\) "(\\|\/)" 116 117--Iteration 19 -- 118string\(1\) "(\\|\/)" 119 120--Iteration 20 -- 121string\(1\) "." 122 123--Iteration 21 -- 124string\(4\) "(\\|\/)foo" 125 126--Iteration 22 -- 127string\(1\) "." 128 129--Iteration 23 -- 130string\(4\) "(\\|\/)foo" 131 132--Iteration 24 -- 133string\(3\) "foo" 134 135--Iteration 25 -- 136string\(1\) "." 137 138--Iteration 26 -- 139string\(1\) "(\\|\/)" 140 141--Iteration 27 -- 142string\(1\) "(\\|\/)" 143 144--Iteration 28 -- 145string\(1\) "." 146 147--Iteration 29 -- 148string\(8\) "(\\|\/)foo\x00bar" 149Done 150