Annotation of embedaddon/php/ext/standard/tests/file/rename_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test rename() function: usage variations-2
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: /* creating directory */
13: $file_path = dirname(__FILE__);
14:
15: // rename dirs across directories
16: echo "\n*** Testing rename() : renaming directory across directories ***\n";
17: $src_dirs = array (
18: /* Testing simple directory tree */
19: "$file_path/rename_variation/",
20:
21: /* Testing a dir with trailing slash */
22: "$file_path/rename_variation/",
23:
24: /* Testing dir with double trailing slashes */
25: "$file_path//rename_variation//",
26: );
27:
28: $dest_dir = "$file_path/rename_variation_dir";
29: // create the $dest_dir
30: mkdir($dest_dir);
31:
32: $counter = 1;
33: /* loop through each $src_dirs and rename it to $dest_dir */
34: foreach($src_dirs as $src_dir) {
35: echo "-- Iteration $counter --\n";
36:
37: // create the src dir
38: mkdir("$file_path/rename_variation/");
39: // rename the src dir to a new dir in dest dir
40: var_dump( rename($src_dir, $dest_dir."/new_dir") );
41: // ensure that dir was renamed
42: var_dump( file_exists($src_dir) ); // expecting false
43: var_dump( file_exists($dest_dir."/new_dir") ); // expecting true
44:
45: // remove the new dir
46: rmdir($dest_dir."/new_dir");
47: $counter++;
48: }
49:
50: echo "Done\n";
51: ?>
52: --CLEAN--
53: <?php
54: $file_path = dirname(__FILE__);
55: rmdir($file_path."/rename_variation_dir");
56: ?>
57: --EXPECTF--
58: *** Testing rename() : renaming directory across directories ***
59: -- Iteration 1 --
60: bool(true)
61: bool(false)
62: bool(true)
63: -- Iteration 2 --
64: bool(true)
65: bool(false)
66: bool(true)
67: -- Iteration 3 --
68: bool(true)
69: bool(false)
70: bool(true)
71: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>