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/*
13 *  Prototype: array stat ( string $filename );
14 *  Description: Gives information about a file
15 */
16
17/* test the effects of rename() on 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_variation1/");  // temp dir
25
26$file_handle = fopen("$file_path/stat_variation1.tmp", "w");  // temp file
27fclose($file_handle);
28
29
30echo "*** Testing stat(): on file and directory ater renaming them ***\n";
31
32// renaming a file
33echo "-- Testing stat() for files after being renamed --\n";
34$old_filename = "$file_path/stat_variation1.tmp";
35$new_filename = "$file_path/stat_variation1a.tmp";
36$old_stat = stat($old_filename);
37clearstatcache();
38sleep(2);
39var_dump( rename($old_filename, $new_filename) );
40$new_stat = stat($new_filename);
41
42// compare the self stat
43var_dump( compare_self_stat($old_stat) );
44var_dump( compare_self_stat($new_stat) );
45
46// compare the two stats
47var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) );
48// clear the cache
49clearstatcache();
50
51// renaming a directory
52echo "-- Testing stat() for directory after being renamed --\n";
53$old_dirname = "$file_path/stat_variation1";
54$new_dirname = "$file_path/stat_variation1a";
55$old_stat = stat($old_dirname);
56clearstatcache();
57sleep(2);
58var_dump( rename($old_dirname, $new_dirname) );
59$new_stat = stat($new_dirname);
60
61// compare self stats
62var_dump( compare_self_stat($old_stat) );
63var_dump( compare_self_stat($new_stat) );
64
65// compare the two stats
66var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
67// clear the cache
68clearstatcache();
69
70
71echo "\n*** Done ***";
72?>
73
74--CLEAN--
75<?php
76$file_path = dirname(__FILE__);
77unlink("$file_path/stat_variation1a.tmp");
78rmdir("$file_path/stat_variation1a");
79?>
80--EXPECTF--
81*** Testing stat(): on file and directory ater renaming them ***
82-- Testing stat() for files after being renamed --
83bool(true)
84bool(true)
85bool(true)
86bool(true)
87-- Testing stat() for directory after being renamed --
88bool(true)
89bool(true)
90bool(true)
91bool(true)
92
93*** Done ***
94
95