dirname_basic.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. --TEST--
  2. Test 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. /* path with only files and trailing slashes*/
  17. "/foo/bar.gz",
  18. "foo/bar.gz",
  19. "bar.gz",
  20. "bar.gz/",
  21. "/bar.gz",
  22. "/bar.gz/",
  23. "/foo/bar.gz/",
  24. "foo/bar.gz/",
  25. "/bar.gz/",
  26. /* path with file extension and trailing slashes */
  27. "/.gz",
  28. ".gz",
  29. "/foo/.gz",
  30. ".gz/",
  31. "/foo/.gz/",
  32. "foo/.gz/",
  33. /* paths with binary value to check if the function is binary safe*/
  34. "foo".chr(0)."bar",
  35. "/foo".chr(0)."bar/",
  36. "/foo".chr(0)."bar",
  37. "foo".chr(0)."bar/",
  38. "/foo".chr(0)."bar/t.gz"
  39. );
  40. function check_dirname( $paths ) {
  41. $loop_counter = 0;
  42. $noOfPaths = count($paths);
  43. for( ; $loop_counter < $noOfPaths; $loop_counter++ ) {
  44. echo "\n--Iteration ";
  45. echo $loop_counter + 1;
  46. echo " --\n";
  47. var_dump( dirname($paths[$loop_counter]) );
  48. }
  49. }
  50. echo "*** Testing basic operations ***\n";
  51. check_dirname( $file_paths );
  52. echo "Done\n";
  53. ?>
  54. --EXPECTREGEX--
  55. \*\*\* Testing basic operations \*\*\*
  56. --Iteration 1 --
  57. string\(1\) "."
  58. --Iteration 2 --
  59. string\(4\) "(\\|\/)foo"
  60. --Iteration 3 --
  61. string\(3\) "foo"
  62. --Iteration 4 --
  63. string\(1\) "(\\|\/)"
  64. --Iteration 5 --
  65. string\(1\) "."
  66. --Iteration 6 --
  67. string\(1\) "(\\|\/)"
  68. --Iteration 7 --
  69. string\(4\) "(\\|\/)foo"
  70. --Iteration 8 --
  71. string\(3\) "foo"
  72. --Iteration 9 --
  73. string\(1\) "(\\|\/)"
  74. --Iteration 10 --
  75. string\(4\) "(\\|\/)foo"
  76. --Iteration 11 --
  77. string\(3\) "foo"
  78. --Iteration 12 --
  79. string\(1\) "."
  80. --Iteration 13 --
  81. string\(1\) "."
  82. --Iteration 14 --
  83. string\(1\) "(\\|\/)"
  84. --Iteration 15 --
  85. string\(1\) "(\\|\/)"
  86. --Iteration 16 --
  87. string\(4\) "(\\|\/)foo"
  88. --Iteration 17 --
  89. string\(3\) "foo"
  90. --Iteration 18 --
  91. string\(1\) "(\\|\/)"
  92. --Iteration 19 --
  93. string\(1\) "(\\|\/)"
  94. --Iteration 20 --
  95. string\(1\) "."
  96. --Iteration 21 --
  97. string\(4\) "(\\|\/)foo"
  98. --Iteration 22 --
  99. string\(1\) "."
  100. --Iteration 23 --
  101. string\(4\) "(\\|\/)foo"
  102. --Iteration 24 --
  103. string\(3\) "foo"
  104. --Iteration 25 --
  105. string\(1\) "."
  106. --Iteration 26 --
  107. string\(1\) "(\\|\/)"
  108. --Iteration 27 --
  109. string\(1\) "(\\|\/)"
  110. --Iteration 28 --
  111. string\(1\) "."
  112. --Iteration 29 --
  113. string\(8\) "(\\|\/)foo\x00bar"
  114. Done