1--TEST-- 2Test lstat() and stat() functions: usage variations - effects of truncate() 3--SKIPIF-- 4<?php 5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); 6if (substr(PHP_OS, 0, 3) == 'WIN') { 7 die('skip.. Not valid for Windows'); 8} 9?> 10--FILE-- 11<?php 12/* test the effects of truncate() on stats of a file */ 13 14$file_path = __DIR__; 15require "$file_path/file.inc"; 16 17 18/* create temp file */ 19$filename = "$file_path/lstat_stat_variation21.tmp"; 20$fp = fopen($filename, "w"); // temp file 21fclose($fp); 22 23/* ftruncate the current file and check stat() on the file */ 24 25echo "*** Testing stat() on file by truncating it to given size ***\n"; 26$old_stat = stat($filename); 27// clear the cache 28clearstatcache(); 29sleep(1); 30// opening file in r/w mode 31$file_handle = fopen($filename, "r+"); 32var_dump( ftruncate($file_handle, 512) ); // truncate it 33fclose($file_handle); 34 35$new_stat = stat($filename); 36// compare self stats 37var_dump( compare_self_stat($old_stat) ); 38var_dump( compare_self_stat($new_stat) ); 39// compare the stat 40$affected_members = array(7, 9, 10, 'size', 'mtime', 'ctime'); 41var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') ); 42 43echo "\n--- Done ---"; 44?> 45--CLEAN-- 46<?php 47$file_path = __DIR__; 48unlink("$file_path/lstat_stat_variation21.tmp"); 49?> 50--EXPECT-- 51*** Testing stat() on file by truncating it to given size *** 52bool(true) 53bool(true) 54bool(true) 55bool(true) 56 57--- Done --- 58