stat_variation2-win32.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --TEST--
  2. Test stat() functions: usage variations - effects of writing to 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 writing to a file on the stats of the file */
  16. $file_path = dirname(__FILE__);
  17. require "$file_path/file.inc";
  18. $filename = "$file_path/stat_variation2.tmp";
  19. $file_handle = fopen($filename, "w"); // temp file
  20. fclose($file_handle);
  21. echo "*** Testing stat(): writing to a file ***\n";
  22. // writing to an empty file
  23. echo "-- Testing stat() on file after data is written in it --\n";
  24. $old_stat = stat($filename);
  25. clearstatcache();
  26. sleep(2);
  27. $file_handle = fopen($filename, "w"); // temp file
  28. fwrite($file_handle, "Hello World");
  29. fclose($file_handle);
  30. $new_stat = stat($filename);
  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. $comp_arr = array(7, 'size');
  36. var_dump(compare_stats($old_stat, $new_stat, $comp_arr, "<"));
  37. clearstatcache();
  38. echo "\n*** Done ***";
  39. ?>
  40. --CLEAN--
  41. <?php
  42. $file_path = dirname(__FILE__);
  43. unlink("$file_path/stat_variation2.tmp");
  44. ?>
  45. --EXPECTF--
  46. *** Testing stat(): writing to a file ***
  47. -- Testing stat() on file after data is written in it --
  48. bool(true)
  49. bool(true)
  50. bool(true)
  51. *** Done ***