1--TEST--
2Test stat() functions: usage variations - effects of is_dir() & is_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 on the stats of dir/file for using is_dir() & is_file() on dir/file */
13
14$file_path = __DIR__;
15require "$file_path/file.inc";
16
17
18/* create temp file and directory */
19mkdir("$file_path/stat_variation4/");  // temp dir
20
21$file_handle = fopen("$file_path/stat_variation4.tmp", "w");  // temp file
22fclose($file_handle);
23
24
25echo "\n*** Testing stat(): on file and directory after accessing it
26    with is_dir() and is_file() functions ***\n";
27
28// is_dir() on a directory
29echo "-- Testing on Directory --\n";
30$old_dirname = "$file_path/stat_variation4";
31$old_stat = stat($old_dirname);
32// clear the cache
33clearstatcache();
34sleep(1);
35var_dump( is_dir($old_dirname) );
36$new_stat = stat($old_dirname);
37
38// compare self stats
39var_dump( compare_self_stat($old_stat) );
40var_dump( compare_self_stat($new_stat) );
41// compare the stat
42var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "==") );
43// clear the stat
44clearstatcache();
45
46
47// is_file() on a file
48echo "-- Testing on file --\n";
49$old_filename = "$file_path/stat_variation4.tmp";
50$old_stat = stat($old_filename);
51// clear the stat
52clearstatcache();
53sleep(2);
54var_dump( is_file($old_filename) );
55$new_stat = stat($old_filename);
56// compare self stats
57var_dump( compare_self_stat($old_stat) );
58var_dump( compare_self_stat($new_stat) );
59// compare the stat
60var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "==") );
61// clear the stat
62clearstatcache();
63
64echo "\n*** Done ***";
65?>
66--CLEAN--
67<?php
68$file_path = __DIR__;
69unlink("$file_path/stat_variation4.tmp");
70rmdir("$file_path/stat_variation4");
71?>
72--EXPECT--
73*** Testing stat(): on file and directory after accessing it
74    with is_dir() and is_file() functions ***
75-- Testing on Directory --
76bool(true)
77bool(true)
78bool(true)
79bool(true)
80-- Testing on file --
81bool(true)
82bool(true)
83bool(true)
84bool(true)
85
86*** Done ***
87