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