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