file_variation5-win32-mb.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. file() with various paths
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die('skip windows only test');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. $script_directory = __DIR__;
  12. chdir($script_directory);
  13. $test_dirname = basename(__FILE__, ".php") . "私はガラスを食べられますtestdir";
  14. mkdir($test_dirname);
  15. $filepath = __FILE__ . ".tmp";
  16. $filename = basename($filepath);
  17. $fd = fopen($filepath, "w+");
  18. fwrite($fd, "Line 1\nLine 2\nLine 3");
  19. fclose($fd);
  20. echo "file() on a path containing .. and .\n";
  21. var_dump(file("./$test_dirname/../$filename"));
  22. echo "\nfile() on a path containing .. with invalid directories\n";
  23. var_dump(file("./$test_dirname/bad_dir/../../$filename"));
  24. echo "\nfile() on a relative path from a different working directory\n";
  25. chdir($test_dirname);
  26. var_dump(file("../$filename"));
  27. chdir($script_directory);
  28. chdir($script_directory);
  29. unlink($filepath);
  30. rmdir($test_dirname);
  31. ?>
  32. --EXPECT--
  33. file() on a path containing .. and .
  34. array(3) {
  35. [0]=>
  36. string(7) "Line 1
  37. "
  38. [1]=>
  39. string(7) "Line 2
  40. "
  41. [2]=>
  42. string(6) "Line 3"
  43. }
  44. file() on a path containing .. with invalid directories
  45. array(3) {
  46. [0]=>
  47. string(7) "Line 1
  48. "
  49. [1]=>
  50. string(7) "Line 2
  51. "
  52. [2]=>
  53. string(6) "Line 3"
  54. }
  55. file() on a relative path from a different working directory
  56. array(3) {
  57. [0]=>
  58. string(7) "Line 1
  59. "
  60. [1]=>
  61. string(7) "Line 2
  62. "
  63. [2]=>
  64. string(6) "Line 3"
  65. }