Annotation of embedaddon/php/ext/standard/tests/file/rename_variation8.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.. not 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: unlink(dirname(__FILE__)."/rename_basic_new2.tmp");
49: rmdir(dirname(__FILE__)."/rename_basic_dir1");
50: ?>
51: --EXPECTF--
52: *** Testing rename() on non-existing file ***
53:
54: Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): No such file or directory in %s on line %d
55: bool(false)
56: bool(false)
57: bool(false)
58:
59: *** Testing rename() on existing directory ***
60: bool(true)
61: bool(false)
62: bool(true)
63:
64: *** Testing rename() on non-existing directory ***
65:
66: Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): No such file or directory in %s on line %d
67: bool(false)
68: bool(false)
69: bool(false)
70: Done
71:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>