1--TEST--
2Test lstat() and stat() functions: usage variations - effects of rename() on file
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip.. Not valid for Windows');
7}
8?>
9--FILE--
10<?php
11/* Prototype: array lstat ( string $filename );
12   Description: Gives information about a file or symbolic link
13
14   Prototype: array stat ( string $filename );
15   Description: Gives information about a file
16*/
17
18/* test the effects of rename() on stats of file */
19
20$file_path = dirname(__FILE__);
21require "$file_path/file.inc";
22
23/* create temp file */
24$fp = fopen("$file_path/lstat_stat_variation1.tmp", "w");  // temp file
25fclose($fp);
26
27// renaming a file and check stat
28echo "*** Testing stat() for files after being renamed ***\n";
29$file_path = dirname(__FILE__);
30$old_filename = "$file_path/lstat_stat_variation1.tmp";
31$new_filename = "$file_path/lstat_stat_variation1a.tmp";
32$old_stat = stat($old_filename);
33clearstatcache();
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
46echo "\n--- Done ---";
47?>
48
49--CLEAN--
50<?php
51$file_path = dirname(__FILE__);
52unlink("$file_path/lstat_stat_variation1a.tmp");
53?>
54--EXPECTF--
55*** Testing stat() for files after being renamed ***
56bool(true)
57bool(true)
58bool(true)
59bool(true)
60
61--- Done ---
62