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