Annotation of embedaddon/php/ext/standard/tests/file/rename_variation9.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test rename() function: basic functionality
3: --FILE--
4: <?php
5: /* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
6: Description: Renames a file or directory
7: */
8:
9: echo "\n*** Testing rename() by giving stream context as third argument ***\n";
10: $file_path = dirname(__FILE__);
11:
12: $context = stream_context_create();
13:
14: // on directory
15: $dir_name = "$file_path/rename_variation_dir9";
16: $new_dir_name = "$file_path/rename_variation_dir9_new";
17:
18: mkdir($dir_name);
19:
20: var_dump( rename($dir_name, $new_dir_name, $context) );
21: var_dump( file_exists($dir_name) ); // expecting flase
22: var_dump( file_exists($new_dir_name) ); // expecting true
23:
24: //on file
25: $src_name = "$file_path/rename_variation9.tmp";
26: $dest_name = "$file_path/rename_variation9_new.tmp";
27:
28: // create the file
29: $fp = fopen($src_name, "w");
30: $s1 = stat($src_name);
31: fclose($fp);
32:
33: var_dump( rename($src_name, $dest_name, $context) );
34: var_dump( file_exists($src_name) ); // expecting false
35: var_dump( file_exists($dest_name) ); // expecting true
36:
37: echo "Done\n";
38: ?>
39: --CLEAN--
40: <?php
41: unlink(dirname(__FILE__)."/rename_variation9_new.tmp");
42: rmdir(dirname(__FILE__)."/rename_variation_dir9_new");
43: ?>
44: --EXPECT--
45: *** Testing rename() by giving stream context as third argument ***
46: bool(true)
47: bool(false)
48: bool(true)
49: bool(true)
50: bool(false)
51: bool(true)
52: Done
53:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>