Return to rename_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
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 "*** Testing rename() on non-existing file ***\n"; 10: $file_path = dirname(__FILE__); 11: require "$file_path/file.inc"; 12: 13: $src_name = "$file_path/rename_basic.tmp"; 14: $dest_name = "$file_path/rename_basic_new.tmp"; 15: 16: // create the file 17: $fp = fopen($src_name, "w"); 18: $old_stat = stat($src_name); 19: fclose($fp); 20: 21: var_dump( rename($src_name, $dest_name) ); // expecting true 22: var_dump( file_exists($src_name) ); // expecting false 23: var_dump( file_exists($dest_name) ); // expecting true 24: 25: $new_stat = stat("$file_path/rename_basic_new.tmp"); 26: 27: // checking statistics of old and renamed file - both should be same except ctime 28: $keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 29: "dev", "ino", "mode", "nlink", "uid", "gid", 30: "rdev", "size", "atime", "mtime", "blksize", "blocks"); 31: var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) ); 32: 33: ?> 34: ===Done=== 35: --CLEAN-- 36: <?php 37: unlink(dirname(__FILE__)."/rename_basic_new.tmp"); 38: ?> 39: --EXPECT-- 40: *** Testing rename() on non-existing file *** 41: bool(true) 42: bool(false) 43: bool(true) 44: bool(true) 45: ===Done===