1--TEST--
2Test rename() function: usage variations-3
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip.. only for Linux');
7}
8?>
9--FILE--
10<?php
11
12$file_path = dirname(__FILE__);
13
14$dest_dir = "$file_path/rename_variation2_dir";
15// create the $dest_dir
16mkdir($dest_dir);
17
18/* Testing rename() on soft and hard links with different permissions */
19echo "\n*** Testing rename() on soft links ***\n";
20// create the file
21$filename = $file_path."/rename_variation2.tmp";
22@unlink($filename);
23var_dump(touch($filename));
24
25// create the soft links to the file
26$linkname = $file_path."/rename_variation2_soft_link1.tmp";
27var_dump(symlink($filename, $linkname));
28
29//rename the link to a new name in the same dir
30$dest_linkname = $file_path."/rename_variation2_soft_link2.tmp";
31var_dump( rename( $linkname, $dest_linkname) );
32//ensure that link was renamed
33clearstatcache();
34var_dump( file_exists($linkname) );  // expecting false
35var_dump( file_exists($dest_linkname) );  // expecting true
36
37// rename a link across dir
38var_dump( rename($dest_linkname, $dest_dir."/rename_variation2_soft_link2.tmp"));
39//ensure that link got renamed
40clearstatcache();
41var_dump( file_exists($dest_linkname) );  // expecting false
42var_dump( file_exists($dest_dir."/rename_variation2_soft_link2.tmp") ); // expecting true
43
44// delete the link file now
45unlink($dest_dir."/rename_variation2_soft_link2.tmp");
46
47echo "Done\n";
48?>
49--CLEAN--
50<?php
51$file_path = dirname(__FILE__);
52unlink($file_path."/rename_variation2.tmp");
53rmdir($file_path."/rename_variation2_dir");
54?>
55--EXPECTF--
56*** Testing rename() on soft links ***
57bool(true)
58bool(true)
59bool(true)
60bool(false)
61bool(true)
62bool(true)
63bool(false)
64bool(true)
65Done
66