stat_variation8-win32.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --TEST--
  2. Test stat() functions: usage variations - effects of truncate()
  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 truncate() on stats of file */
  16. $file_path = dirname(__FILE__);
  17. require "$file_path/file.inc";
  18. /* create temp file and directory */
  19. $filename = "$file_path/stat_variation8.tmp";
  20. $file_handle = fopen($filename, "w"); // temp file
  21. fclose($file_handle);
  22. echo "\n*** Testing stat(): on file by truncating it to given size ***\n";
  23. // create temp file
  24. $file_handle = fopen($filename, "w");
  25. fclose($file_handle);
  26. clearstatcache(true, $filename);
  27. $old_stat = stat($filename);
  28. // clear the cache
  29. sleep(2);
  30. // opening file in r/w mode
  31. $file_handle = fopen($filename, "r+");
  32. var_dump( ftruncate($file_handle, 512) ); // truncate it
  33. fclose($file_handle);
  34. clearstatcache(true, $filename);
  35. $new_stat = stat($filename);
  36. // compare self stats
  37. var_dump( compare_self_stat($old_stat) );
  38. var_dump( compare_self_stat($new_stat) );
  39. // compare the stat
  40. $affected_members = array(7, 9, 'size', 'mtime');
  41. var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') );
  42. // clear the stat
  43. clearstatcache(true, $filename); // clear previous size value in cache
  44. echo "\n*** Done ***";
  45. ?>
  46. --CLEAN--
  47. <?php
  48. $file_path = dirname(__FILE__);
  49. unlink("$file_path/stat_variation8.tmp");
  50. ?>
  51. --EXPECTF--
  52. *** Testing stat(): on file by truncating it to given size ***
  53. bool(true)
  54. bool(true)
  55. bool(true)
  56. bool(true)
  57. *** Done ***