1--TEST--
2Test stat() functions: usage variations - effects of writing to 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 writing to a file on the stats of the file */
18
19
20$file_path = dirname(__FILE__);
21require "$file_path/file.inc";
22
23
24$filename = "$file_path/stat_variation2.tmp";
25$file_handle = fopen($filename, "w");  // temp file
26fclose($file_handle);
27
28
29echo "*** Testing stat(): writing to a file ***\n";
30
31// writing to an empty file
32echo "-- Testing stat() on file after data is written in it --\n";
33$old_stat = stat($filename);
34clearstatcache();
35sleep(2);
36$file_handle = fopen($filename, "w");  // temp file
37fwrite($file_handle, "Hello World");
38fclose($file_handle);
39$new_stat = stat($filename);
40
41// compare self stats
42var_dump( compare_self_stat($old_stat) );
43var_dump( compare_self_stat($new_stat) );
44// compare the stats
45$comp_arr = array(7, 'size');
46var_dump(compare_stats($old_stat, $new_stat, $comp_arr, "<"));
47clearstatcache();
48
49echo "\n*** Done ***";
50?>
51--CLEAN--
52<?php
53$file_path = dirname(__FILE__);
54unlink("$file_path/stat_variation2.tmp");
55?>
56--EXPECT--
57*** Testing stat(): writing to a file ***
58-- Testing stat() on file after data is written in it --
59bool(true)
60bool(true)
61bool(true)
62
63*** Done ***
64