basename_basic-win32.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. --TEST--
  2. basename() basic functionality
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die('skip Windows only basename tests');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. $file_paths = array (
  12. /* simple paths (forward slashes) */
  13. "bar",
  14. "/foo/bar",
  15. "foo/bar",
  16. "/bar",
  17. /* simple paths with trailing slashes (forward slashes) */
  18. "bar/",
  19. "/bar/",
  20. "/foo/bar/",
  21. "foo/bar/",
  22. "/bar/",
  23. /* simple paths (backslashes) */
  24. "bar",
  25. "\\foo\\bar",
  26. "foo\\bar",
  27. "\\bar",
  28. /* simple paths with trailing slashes (backslashes) */
  29. "bar\\",
  30. "\\bar\\",
  31. "\\foo\\bar\\",
  32. "foo\\bar\\",
  33. "\\bar\\",
  34. /* paths with numeric strings */
  35. "10.5\\10.5",
  36. "10.5/10.5",
  37. "10.5",
  38. "105",
  39. "/10.5",
  40. "\\10.5",
  41. "10.5/",
  42. "10.5\\",
  43. "10/10.zip",
  44. "0",
  45. '0',
  46. /* path with spaces */
  47. " ",
  48. ' ',
  49. /* empty paths */
  50. "",
  51. '',
  52. );
  53. foreach ($file_paths as $file_path) {
  54. var_dump(basename($file_path));
  55. }
  56. ?>
  57. --EXPECT--
  58. string(3) "bar"
  59. string(3) "bar"
  60. string(3) "bar"
  61. string(3) "bar"
  62. string(3) "bar"
  63. string(3) "bar"
  64. string(3) "bar"
  65. string(3) "bar"
  66. string(3) "bar"
  67. string(3) "bar"
  68. string(3) "bar"
  69. string(3) "bar"
  70. string(3) "bar"
  71. string(3) "bar"
  72. string(3) "bar"
  73. string(3) "bar"
  74. string(3) "bar"
  75. string(3) "bar"
  76. string(4) "10.5"
  77. string(4) "10.5"
  78. string(4) "10.5"
  79. string(3) "105"
  80. string(4) "10.5"
  81. string(4) "10.5"
  82. string(4) "10.5"
  83. string(4) "10.5"
  84. string(6) "10.zip"
  85. string(1) "0"
  86. string(1) "0"
  87. string(1) " "
  88. string(1) " "
  89. string(0) ""
  90. string(0) ""