Annotation of embedaddon/php/ext/standard/tests/file/rename_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test rename() function: usage variations-6
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: /* test rename() by trying to rename an existing file/dir/link to the same name
13: and one another */
14: // create a dir
15: $file_path = dirname(__FILE__);
16: $dirname = "$file_path/rename_variation_dir";
17: mkdir($dirname);
18: //create a file
19: $filename = "$file_path/rename_variation.tmp";
20: $fp = fopen($filename, "w");
21: fclose($fp);
22: // create a link
23: $linkname = "$file_path/rename_variation_link.tmp";
24: symlink($filename, $linkname);
25:
26: echo "\n-- Renaming link to same link name --\n";
27: var_dump( rename($linkname, $linkname) );
28:
29: echo "\n-- Renaming file to same file name --\n";
30: var_dump( rename($filename, $filename) );
31:
32: echo "\n-- Renaming directory to same directory name --\n";
33: var_dump( rename($dirname, $dirname) );
34:
35: echo "\n-- Renaming existing link to existing directory name --\n";
36: var_dump( rename($linkname, $dirname) );
37: echo "\n-- Renaming existing link to existing file name --\n";
38: var_dump( rename($linkname, $filename) );
39:
40: echo "\n-- Renaming existing file to existing directory name --\n";
41: var_dump( rename($filename, $dirname) );
42: echo "\n-- Renaming existing file to existing link name --\n";
43: var_dump( rename($filename, $linkname) );
44:
45: echo "\n-- Renaming existing directory to existing file name --\n";
46: $fp = fopen($filename, "w");
47: fclose($fp);
48: var_dump( rename($dirname, $filename) );
49: echo "\n-- Renaming existing directory to existing link name --\n";
50: var_dump( rename($dirname, $linkname) );
51:
52: echo "Done\n";
53: ?>
54: --CLEAN--
55: <?php
56: $file_path = dirname(__FILE__);
57: unlink($file_path."/rename_variation_link.tmp");
58: unlink($file_path."/rename_variation.tmp");
59: rmdir($file_path."/rename_variation_dir");
60: ?>
61: --EXPECTF--
62: -- Renaming link to same link name --
63: bool(true)
64:
65: -- Renaming file to same file name --
66: bool(true)
67:
68: -- Renaming directory to same directory name --
69: bool(true)
70:
71: -- Renaming existing link to existing directory name --
72:
73: Warning: rename(%s,%s): Is a directory in %s on line %d
74: bool(false)
75:
76: -- Renaming existing link to existing file name --
77: bool(true)
78:
79: -- Renaming existing file to existing directory name --
80:
81: Warning: rename(%s,%s): Is a directory in %s on line %d
82: bool(false)
83:
84: -- Renaming existing file to existing link name --
85: bool(true)
86:
87: -- Renaming existing directory to existing file name --
88:
89: Warning: rename(%s,%s): Not a directory in %s on line %d
90: bool(false)
91:
92: -- Renaming existing directory to existing link name --
93:
94: Warning: rename(%s,%s): Not a directory in %s on line %d
95: bool(false)
96: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>