stat_variation3-win32.phpt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --TEST--
  2. Test stat() functions: usage variations - effects of creating/deleting the dir/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 of creating & deleting of subdir/file on the 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_variation3/"); // temp dir
  20. echo "*** Testing stat(): with creating & deleting subdir/file ***\n";
  21. // creating and deleting subdir and files in the dir
  22. echo "-- Testing stat() on dir after subdir and file is created in it --\n";
  23. $dirname = "$file_path/stat_variation3";
  24. $old_stat = stat($dirname);
  25. clearstatcache();
  26. sleep(2);
  27. mkdir("$dirname/stat_variation3_subdir");
  28. $file_handle = fopen("$dirname/stat_variation3a.tmp", "w");
  29. fclose($file_handle);
  30. $new_stat = stat($dirname);
  31. // compare self stats
  32. var_dump( compare_self_stat($old_stat) );
  33. var_dump( compare_self_stat($new_stat) );
  34. // compare the stats
  35. $affected_members = array( 9, 'mtime');
  36. clearstatcache();
  37. sleep(2);
  38. var_dump(compare_stats($old_stat, $new_stat, $affected_members, "<"));
  39. unlink("$dirname/stat_variation3a.tmp");
  40. rmdir("$dirname/stat_variation3_subdir");
  41. clearstatcache();
  42. // comparing stats after the deletion of subdir and file
  43. echo "-- Testing stat() for comparing stats after the deletion of subdir and file --\n";
  44. $new_stat1 = stat($dirname);
  45. // compare self stats
  46. var_dump( compare_self_stat($new_stat1) );
  47. // compare the stats
  48. var_dump(compare_stats($new_stat, $new_stat1, $all_stat_keys, "="));
  49. clearstatcache();
  50. echo "\n*** Done ***";
  51. ?>
  52. --CLEAN--
  53. <?php
  54. $file_path = dirname(__FILE__);
  55. rmdir("$file_path/stat_variation3");
  56. ?>
  57. --EXPECTF--
  58. *** Testing stat(): with creating & deleting subdir/file ***
  59. -- Testing stat() on dir after subdir and file is created in it --
  60. bool(true)
  61. bool(true)
  62. bool(true)
  63. -- Testing stat() for comparing stats after the deletion of subdir and file --
  64. bool(true)
  65. bool(true)
  66. *** Done ***