stat_variation1-win32.phpt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /*
  12. * Prototype: array stat ( string $filename );
  13. * Description: Gives information about a file
  14. */
  15. /* test the effects of rename() on stats of dir/file */
  16. $file_path = dirname(__FILE__);
  17. require "$file_path/file.inc";
  18. /* create temp file and directory */
  19. mkdir("$file_path/stat_variation1/"); // temp dir
  20. $file_handle = fopen("$file_path/stat_variation1.tmp", "w"); // temp file
  21. fclose($file_handle);
  22. echo "*** Testing stat(): on file and directory ater renaming them ***\n";
  23. // renaming a file
  24. echo "-- Testing stat() for files after being renamed --\n";
  25. $old_filename = "$file_path/stat_variation1.tmp";
  26. $new_filename = "$file_path/stat_variation1a.tmp";
  27. $old_stat = stat($old_filename);
  28. clearstatcache();
  29. sleep(2);
  30. var_dump( rename($old_filename, $new_filename) );
  31. $new_stat = stat($new_filename);
  32. // compare the self stat
  33. var_dump( compare_self_stat($old_stat) );
  34. var_dump( compare_self_stat($new_stat) );
  35. // compare the two stats
  36. var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) );
  37. // clear the cache
  38. clearstatcache();
  39. // renaming a directory
  40. echo "-- Testing stat() for directory after being renamed --\n";
  41. $old_dirname = "$file_path/stat_variation1";
  42. $new_dirname = "$file_path/stat_variation1a";
  43. $old_stat = stat($old_dirname);
  44. clearstatcache();
  45. sleep(2);
  46. var_dump( rename($old_dirname, $new_dirname) );
  47. $new_stat = stat($new_dirname);
  48. // compare self stats
  49. var_dump( compare_self_stat($old_stat) );
  50. var_dump( compare_self_stat($new_stat) );
  51. // compare the two stats
  52. var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
  53. // clear the cache
  54. clearstatcache();
  55. echo "\n*** Done ***";
  56. ?>
  57. --CLEAN--
  58. <?php
  59. $file_path = dirname(__FILE__);
  60. unlink("$file_path/stat_variation1a.tmp");
  61. rmdir("$file_path/stat_variation1a");
  62. ?>
  63. --EXPECTF--
  64. *** Testing stat(): on file and directory ater renaming them ***
  65. -- Testing stat() for files after being renamed --
  66. bool(true)
  67. bool(true)
  68. bool(true)
  69. bool(true)
  70. -- Testing stat() for directory after being renamed --
  71. bool(true)
  72. bool(true)
  73. bool(true)
  74. bool(true)
  75. *** Done ***