Annotation of embedaddon/php/ext/standard/tests/file/rename_variation3-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test rename() function: usage variations
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) != 'WIN') {
6: die('skip.. only for Windows');
7: }
8: ?>
9: --FILE--
10: <?php
11: /* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
12: Description: Renames a file or directory
13: */
14:
15: require dirname(__FILE__).'/file.inc';
16:
17: /* creating directory */
18: $file_path = dirname(__FILE__);
19: $dirname = "$file_path/rename_variation3_dir";
20: mkdir($dirname);
21:
22: /* test rename() by trying to rename an existing file/dir to the same name
23: and one another */
24:
25: $filename = "$file_path/rename_variation3.tmp";
26: $fp = fopen($filename, "w");
27: if (!$fp) {
28: die("Cannot create $filename\n");
29: }
30: fclose($fp);
31:
32: echo "\n-- Renaming file to same file name --\n";
33: var_dump( rename($filename, $filename) );
34: var_dump( file_exists($filename) );
35:
36: echo "\n-- Renaming directory to same directory name --\n";
37: var_dump( rename($dirname, $dirname) );
38: var_dump( file_exists($dirname) );
39:
40: echo "\n-- Renaming existing file to existing directory name --\n";
41: var_dump( rename($filename, $dirname) );
42: var_dump( file_exists($filename) );
43: var_dump( file_exists($dirname) );
44:
45: echo "\n-- Renaming existing directory to existing file name --\n";
46: $fp = fopen($filename, "w");
47: fclose($fp);
48:
49: var_dump( rename($dirname, $filename) );
50: var_dump( file_exists($filename) );
51: var_dump( file_exists($dirname) );
52:
53: echo "Done\n";
54: ?>
55: --CLEAN--
56: <?php
57: $file_path = dirname(__FILE__);
58: unlink($file_path."/rename_variation3_link.tmp");
59: unlink($file_path."/rename_variation3.tmp");
60: rmdir($file_path."/rename_variation3_dir");
61: rmdir($file_path."/rename_variation3.tmp");
62: ?>
63: --EXPECTF--
64: -- Renaming file to same file name --
65: bool(true)
66: bool(true)
67:
68: -- Renaming directory to same directory name --
69: bool(true)
70: bool(true)
71:
72: -- Renaming existing file to existing directory name --
73:
74: Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): Access is denied. (code: 5) in %s on line %d
75: bool(false)
76: bool(true)
77: bool(true)
78:
79: -- Renaming existing directory to existing file name --
80: bool(true)
81: bool(true)
82: bool(false)
83: Done
84:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>