Annotation of embedaddon/php/ext/standard/tests/file/rename_variation-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: /* create directory */
18: $file_path = dirname(__FILE__);
19: mkdir("$file_path/rename_variation");
20:
21: /* rename files across directories */
22: echo "*** Testing rename() : rename files across directories ***\n";
23: $src_filenames = array(
24: "$file_path/rename_variation/rename_variation.tmp",
25:
26: /* Testing a file trailing slash */
27: "$file_path/rename_variation/rename_variation.tmp/",
28:
29: /* Testing file with double slashes */
30: "$file_path/rename_variation//rename_variation.tmp",
31: "$file_path//rename_variation//rename_variation.tmp",
32: );
33:
34: $counter = 1;
35:
36: /* loop through each $file and rename it to rename_variation2.tmp */
37: foreach($src_filenames as $src_filename) {
38: echo "-- Iteration $counter --\n";
39: $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w");
40: fclose($fp);
41: $dest_filename = "$file_path/rename_variation2.tmp";
42: var_dump( rename($src_filename, $dest_filename) );
43:
44: // ensure that file got renamed to new name
45: var_dump( file_exists($src_filename) ); // expecting false
46: var_dump( file_exists($dest_filename) ); // expecting true
47: $counter++;
48:
49: // unlink the file
50: unlink($dest_filename);
51: }
52:
53: rmdir("$file_path/rename_variation");
54:
55: echo "Done\n";
56: ?>
57: --CLEAN--
58: <?php
59: $file_path = dirname(__FILE__);
60: unlink($file_path."/rename_variation_link.tmp");
61: unlink($file_path."/rename_variation.tmp");
62: rmdir($file_path."/rename_variation_dir");
63: ?>
64: --EXPECTF--
65: *** Testing rename() : rename files across directories ***
66: -- Iteration 1 --
67: bool(true)
68: bool(false)
69: bool(true)
70: -- Iteration 2 --
71:
72: Warning: rename(%s/rename_variation/rename_variation.tmp/,%s/rename_variation2.tmp): The filename, directory name, or volume label syntax is incorrect. (code: 123) in %s on line %d
73: bool(false)
74: bool(false)
75: bool(false)
76:
77: Warning: unlink(%s/rename_variation2.tmp): No such file or directory in %s on line %d
78: -- Iteration 3 --
79: bool(true)
80: bool(false)
81: bool(true)
82: -- Iteration 4 --
83: bool(true)
84: bool(false)
85: bool(true)
86: Done
87:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>