stat_variation4-win32.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. --TEST--
  2. Test stat() functions: usage variations - effects of is_dir() & is_file()
  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 on the stats of dir/file for using is_dir() & is_file() on dir/file */
  16. $file_path = dirname(__FILE__);
  17. require "$file_path/file.inc";
  18. /* create temp file and directory */
  19. mkdir("$file_path/stat_variation4/"); // temp dir
  20. $file_handle = fopen("$file_path/stat_variation4.tmp", "w"); // temp file
  21. fclose($file_handle);
  22. echo "\n*** Testing stat(): on file and directory after accessing it
  23. with is_dir() and is_file() functions ***\n";
  24. // is_dir() on a directory
  25. echo "-- Testing on Directory --\n";
  26. $old_dirname = "$file_path/stat_variation4";
  27. $old_stat = stat($old_dirname);
  28. // clear the cache
  29. clearstatcache();
  30. sleep(2);
  31. var_dump( is_dir($old_dirname) );
  32. $new_stat = stat($old_dirname);
  33. // compare self stats
  34. var_dump( compare_self_stat($old_stat) );
  35. var_dump( compare_self_stat($new_stat) );
  36. // compare the stat
  37. var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") );
  38. // clear the stat
  39. clearstatcache();
  40. // is_file() on a file
  41. echo "-- Testing on file --\n";
  42. $old_filename = "$file_path/stat_variation4.tmp";
  43. $old_stat = stat($old_filename);
  44. // clear the stat
  45. clearstatcache();
  46. sleep(2);
  47. var_dump( is_file($old_filename) );
  48. $new_stat = stat($old_filename);
  49. // compare self stats
  50. var_dump( compare_self_stat($old_stat) );
  51. var_dump( compare_self_stat($new_stat) );
  52. // compare the stat
  53. var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") );
  54. // clear the stat
  55. clearstatcache();
  56. echo "\n*** Done ***";
  57. ?>
  58. --CLEAN--
  59. <?php
  60. $file_path = dirname(__FILE__);
  61. unlink("$file_path/stat_variation4.tmp");
  62. rmdir("$file_path/stat_variation4");
  63. ?>
  64. --EXPECTF--
  65. *** Testing stat(): on file and directory after accessing it
  66. with is_dir() and is_file() functions ***
  67. -- Testing on Directory --
  68. bool(true)
  69. bool(true)
  70. bool(true)
  71. bool(true)
  72. -- Testing on file --
  73. bool(true)
  74. bool(true)
  75. bool(true)
  76. bool(true)
  77. *** Done ***