chmod_variation2-win32-mb.phpt 1.8 KB

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