stat_variation1-win32-mb.phpt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --TEST--
  2. Test stat() functions: usage variations - effects of rename()
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die('skip.. only for Windows');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* test the effects of rename() on stats of dir/file */
  12. $file_path = __DIR__;
  13. require "$file_path/file.inc";
  14. /* create temp file and directory */
  15. mkdir("$file_path/stat_variation1_私はガラスを食べられます/"); // temp dir
  16. $file_handle = fopen("$file_path/stat_variation1_私はガラスを食べられます.tmp", "w"); // temp file
  17. fclose($file_handle);
  18. echo "*** Testing stat(): on file and directory ater renaming them ***\n";
  19. // renaming a file
  20. echo "-- Testing stat() for files after being renamed --\n";
  21. $old_filename = "$file_path/stat_variation1_私はガラスを食べられます.tmp";
  22. $new_filename = "$file_path/stat_variation1a_私はガラスを食べられます.tmp";
  23. $old_stat = stat($old_filename);
  24. clearstatcache();
  25. sleep(1);
  26. var_dump( rename($old_filename, $new_filename) );
  27. $new_stat = stat($new_filename);
  28. // compare the self stat
  29. var_dump( compare_self_stat($old_stat) );
  30. var_dump( compare_self_stat($new_stat) );
  31. // compare the two stats
  32. var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) );
  33. // clear the cache
  34. clearstatcache();
  35. // renaming a directory
  36. echo "-- Testing stat() for directory after being renamed --\n";
  37. $old_dirname = "$file_path/stat_variation1_私はガラスを食べられます";
  38. $new_dirname = "$file_path/stat_variation1a_私はガラスを食べられます";
  39. $old_stat = stat($old_dirname);
  40. clearstatcache();
  41. sleep(2);
  42. var_dump( rename($old_dirname, $new_dirname) );
  43. $new_stat = stat($new_dirname);
  44. // compare self stats
  45. var_dump( compare_self_stat($old_stat) );
  46. var_dump( compare_self_stat($new_stat) );
  47. // compare the two stats
  48. var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
  49. // clear the cache
  50. clearstatcache();
  51. echo "\n*** Done ***";
  52. ?>
  53. --CLEAN--
  54. <?php
  55. $file_path = __DIR__;
  56. unlink("$file_path/stat_variation1a_私はガラスを食べられます.tmp");
  57. rmdir("$file_path/stat_variation1a_私はガラスを食べられます");
  58. ?>
  59. --EXPECT--
  60. *** Testing stat(): on file and directory ater renaming them ***
  61. -- Testing stat() for files after being renamed --
  62. bool(true)
  63. bool(true)
  64. bool(true)
  65. bool(true)
  66. -- Testing stat() for directory after being renamed --
  67. bool(true)
  68. bool(true)
  69. bool(true)
  70. bool(true)
  71. *** Done ***