Return to copy_variation14.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 - non existing src/dest 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 create a copy of non-existing source in an existing destination 11: and an existing source in non-existing destiantion */ 12: 13: $file_path = dirname(__FILE__); 14: 15: echo "*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***"; 16: $file = $file_path."/copy_variation14.tmp"; 17: $file_handle = fopen($file, "w"); 18: fwrite($file_handle, str_repeat(b"Hello2world...\n", 100)); 19: fclose($file_handle); 20: 21: var_dump( copy($file_path."/nosuchfile.tmp", $file_path."/copy_nosuchfile.tmp") ); //With non-existing source 22: var_dump( file_exists($file_path."/copy_nosuchfile.tmp") ); 23: 24: echo "\n*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***"; 25: var_dump( copy($file, $file_path."/nodir/copy_nosuchfile.tmp") ); //With non-existing dir path 26: var_dump( file_exists($file_path."/nodir/copy_nosuchfile.tmp") ); 27: var_dump( filesize($file) ); //size of the source 28: 29: echo "*** Done ***\n"; 30: ?> 31: 32: --CLEAN-- 33: <?php 34: unlink(dirname(__FILE__)."/copy_variation14.tmp"); 35: ?> 36: 37: --EXPECTF-- 38: *** Test copy() function: Trying to create a copy of non-existing source in existing destination *** 39: Warning: copy(%s): %s 40: bool(false) 41: bool(false) 42: 43: *** Test copy() function: Trying to create copy of an existing source in non-existing destination *** 44: Warning: copy(%s): %s 45: bool(false) 46: bool(false) 47: int(1500) 48: *** Done ***