1--TEST--
2Test lstat() and stat() functions: usage variations - effects of rename() on link
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 link */
19
20$file_path = dirname(__FILE__);
21require "$file_path/file.inc";
22
23/* create temp file & link */
24$fp = fopen("$file_path/lstat_stat_variation3.tmp", "w");  // temp file
25fclose($fp);
26
27// temp link
28symlink("$file_path/lstat_stat_variation3.tmp", "$file_path/lstat_stat_variation_link3.tmp");
29
30// renaming a link
31echo "*** Testing lstat() for link after being renamed ***\n";
32$old_linkname = "$file_path/lstat_stat_variation_link3.tmp";
33$new_linkname = "$file_path/lstat_stat_variation_link3a.tmp";
34$old_stat = lstat($old_linkname);
35clearstatcache();
36var_dump( rename($old_linkname, $new_linkname) );
37$new_stat = lstat($new_linkname);
38
39// compare self stats
40var_dump( compare_self_stat($old_stat) );
41var_dump( compare_self_stat($new_stat) );
42
43// compare the two stats - all except ctime
44$keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12,
45                       "dev", "ino", "mode", "nlink", "uid", "gid",
46                       "rdev", "size", "atime", "mtime", "blksize", "blocks");
47var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) );
48?>
49===Done===
50--CLEAN--
51<?php
52$file_path = dirname(__FILE__);
53unlink("$file_path/lstat_stat_variation3.tmp");
54unlink("$file_path/lstat_stat_variation_link3a.tmp");
55?>
56--EXPECT--
57*** Testing lstat() for link after being renamed ***
58bool(true)
59bool(true)
60bool(true)
61bool(true)
62===Done===
63