Return to copy_variation11.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test copy() function: usage variations - existing dir as destination 3: --FILE-- 4: <?php 5: /* Prototype: bool copy ( string $source, string $dest ); 6: Description: Makes a copy of the file source to dest. 7: Returns TRUE on success or FALSE on failure. 8: */ 9: 10: /* Test copy(): Trying to copy the file to a destination, where destination is an existing dir */ 11: 12: $file_path = dirname(__FILE__); 13: 14: echo "*** Test copy() function: Trying to create a copy of source file as a dir ***\n"; 15: $file = $file_path."/copy_variation11.tmp"; 16: $file_handle = fopen($file, "w"); 17: fwrite($file_handle, str_repeat(b"Hello, world...", 20)); 18: fclose($file_handle); 19: 20: $dir = $file_path."/copy_variation11"; 21: mkdir($dir); 22: 23: echo "Size of source before copy operation => "; 24: var_dump( filesize($file) ); //size of source before copy 25: clearstatcache(); 26: echo "Size of destination before copy operation => "; 27: var_dump( filesize($dir) ); //size of destination before copy 28: clearstatcache(); 29: 30: echo "\n-- Now applying copy() operation --\n"; 31: var_dump( copy($file, $dir) ); //expected: bool(false) 32: 33: var_dump( file_exists($file) ); //expected: bool(true) 34: var_dump( file_exists($dir) ); //expected: bool(true) 35: 36: var_dump( is_file($file) ); //expected: bool(true) 37: var_dump( is_dir($file) ); //expected: bool(false) 38: 39: var_dump( is_file($dir) ); //expected: bool(false) 40: var_dump( is_dir($dir) ); //expected: bool(true) 41: 42: var_dump( filesize($file) ); //size of source after copy 43: var_dump( filesize($dir) ); //size of destination after copy 44: 45: echo "*** Done ***\n"; 46: ?> 47: 48: --CLEAN-- 49: <?php 50: unlink(dirname(__FILE__)."/copy_variation11.tmp"); 51: rmdir(dirname(__FILE__)."/copy_variation11"); 52: ?> 53: 54: --EXPECTF-- 55: *** Test copy() function: Trying to create a copy of source file as a dir *** 56: Size of source before copy operation => int(300) 57: Size of destination before copy operation => int(%d) 58: 59: -- Now applying copy() operation -- 60: 61: Warning: %s 62: bool(false) 63: bool(true) 64: bool(true) 65: bool(true) 66: bool(false) 67: bool(false) 68: bool(true) 69: int(300) 70: int(%d) 71: *** Done ***