Annotation of embedaddon/php/ext/standard/tests/file/rename_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test rename() function: usage variations-3
3: --SKIPIF--
4: <?php
5: if (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_variation_dir";
15: // create the $dest_dir
16: mkdir($dest_dir);
17:
18: /* Testing rename() on soft and hard links with different permissions */
19: echo "\n*** Testing rename() on soft links ***\n";
20: // create the file
21: $filename = $file_path."/rename_variation2.tmp";
22: @unlink($filename);
23: var_dump(touch($filename));
24:
25: // create the soft links to the file
26: $linkname = $file_path."/rename_variation_soft_link1.tmp";
27: var_dump(symlink($filename, $linkname));
28:
29: //rename the link to a new name in the same dir
30: $dest_linkname = $file_path."/rename_variation_soft_link2.tmp";
31: var_dump( rename( $linkname, $dest_linkname) );
32: //ensure that link was renamed
33: clearstatcache();
34: var_dump( file_exists($linkname) ); // expecting false
35: var_dump( file_exists($dest_linkname) ); // expecting true
36:
37: // rename a link across dir
38: var_dump( rename($dest_linkname, $dest_dir."/rename_variation_soft_link2.tmp"));
39: //ensure that link got renamed
40: clearstatcache();
41: var_dump( file_exists($dest_linkname) ); // expecting false
42: var_dump( file_exists($dest_dir."/rename_variation_soft_link2.tmp") ); // expecting true
43:
44: // delete the link file now
45: unlink($dest_dir."/rename_variation_soft_link2.tmp");
46:
47: echo "Done\n";
48: ?>
49: --CLEAN--
50: <?php
51: $file_path = dirname(__FILE__);
52: unlink($file_path."/rename_variation2.tmp");
53: rmdir($file_path."/rename_variation_dir");
54: ?>
55: --EXPECTF--
56: *** Testing rename() on soft links ***
57: bool(true)
58: bool(true)
59: bool(true)
60: bool(false)
61: bool(true)
62: bool(true)
63: bool(false)
64: bool(true)
65: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>