1--TEST-- 2Test stat() functions: usage variations - effects of creating/deleting the dir/file 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die('skip.. only for Windows'); 7} 8?> 9--FILE-- 10<?php 11 12/* 13 * Prototype: array stat ( string $filename ); 14 * Description: Gives information about a file 15 */ 16 17/* test the effects of creating & deleting of subdir/file on the stats of dir/file */ 18 19$file_path = dirname(__FILE__); 20require "$file_path/file.inc"; 21 22 23/* create temp file and directory */ 24mkdir("$file_path/stat_variation3/"); // temp dir 25 26echo "*** Testing stat(): with creating & deleting subdir/file ***\n"; 27 28// creating and deleting subdir and files in the dir 29echo "-- Testing stat() on dir after subdir and file is created in it --\n"; 30$dirname = "$file_path/stat_variation3"; 31$old_stat = stat($dirname); 32clearstatcache(); 33sleep(2); 34mkdir("$dirname/stat_variation3_subdir"); 35$file_handle = fopen("$dirname/stat_variation3a.tmp", "w"); 36fclose($file_handle); 37$new_stat = stat($dirname); 38 39// compare self stats 40var_dump( compare_self_stat($old_stat) ); 41var_dump( compare_self_stat($new_stat) ); 42// compare the stats 43$affected_members = array( 9, 'mtime'); 44clearstatcache(); 45sleep(2); 46var_dump(compare_stats($old_stat, $new_stat, $affected_members, "<")); 47unlink("$dirname/stat_variation3a.tmp"); 48rmdir("$dirname/stat_variation3_subdir"); 49clearstatcache(); 50 51// comparing stats after the deletion of subdir and file 52echo "-- Testing stat() for comparing stats after the deletion of subdir and file --\n"; 53$new_stat1 = stat($dirname); 54// compare self stats 55var_dump( compare_self_stat($new_stat1) ); 56// compare the stats 57var_dump(compare_stats($new_stat, $new_stat1, $all_stat_keys, "=")); 58clearstatcache(); 59 60echo "\n*** Done ***"; 61?> 62--CLEAN-- 63<?php 64$file_path = dirname(__FILE__); 65rmdir("$file_path/stat_variation3"); 66?> 67--EXPECTF-- 68*** Testing stat(): with creating & deleting subdir/file *** 69-- Testing stat() on dir after subdir and file is created in it -- 70bool(true) 71bool(true) 72bool(true) 73-- Testing stat() for comparing stats after the deletion of subdir and file -- 74bool(true) 75bool(true) 76 77*** Done *** 78