Annotation of embedaddon/php/ext/standard/tests/file/rename_variation8-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test rename() function: variation
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
6: ?>
7: --FILE--
8: <?php
9: /* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
10: Description: Renames a file or directory
11: */
12:
13: echo "\n*** Testing rename() on non-existing file ***\n";
14: $file_path = dirname(__FILE__);
15:
16: // try renaming a non existing file
17: $src_name = $file_path."/non_existent_file.tmp";
18: $dest_name = $file_path."/rename_variation8_new.tmp";
19: var_dump( rename($src_name, $dest_name) );
20:
21: // ensure that $dest_name didn't get created
22: var_dump( file_exists($src_name) ); // expecting false
23: var_dump( file_exists($dest_name) ); // expecting false
24:
25: // rename a existing dir to new name
26: echo "\n*** Testing rename() on existing directory ***\n";
27: $dir_name = $file_path."/rename_basic_dir";
28: mkdir($dir_name);
29: $new_dir_name = $file_path."/rename_basic_dir1";
30: var_dump( rename($dir_name, $new_dir_name) );
31: //ensure that $new_dir_name got created
32: var_dump( file_exists($dir_name) ); // expecting false
33: var_dump( file_exists($new_dir_name) ); // expecting true
34:
35: // try to rename an non_existing dir
36: echo "\n*** Testing rename() on non-existing directory ***\n";
37: $non_existent_dir_name = $file_path."/non_existent_dir";
38: $new_dir_name = "$file_path/rename_basic_dir2";
39: var_dump( rename($non_existent_dir_name, $new_dir_name) );
40: // ensure that $new_dir_name didn't get created
41: var_dump( file_exists($non_existent_dir_name) ); // expecting flase
42: var_dump( file_exists($new_dir_name) ); // expecting false
43:
44: echo "Done\n";
45: ?>
46: --CLEAN--
47: <?php
48: rmdir(dirname(__FILE__)."/rename_basic_dir1");
49: ?>
50: --EXPECTF--
51: *** Testing rename() on non-existing file ***
52:
53: Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): The system cannot find the file specified. (code: 2) in %s on line %d
54: bool(false)
55: bool(false)
56: bool(false)
57:
58: *** Testing rename() on existing directory ***
59: bool(true)
60: bool(false)
61: bool(true)
62:
63: *** Testing rename() on non-existing directory ***
64:
65: Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): The system cannot find the file specified. (code: 2) in %s on line %d
66: bool(false)
67: bool(false)
68: bool(false)
69: Done
70:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>