Annotation of embedaddon/php/ext/standard/tests/file/copy_variation7.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test copy() function: usage variations - links
! 3: --SKIPIF--
! 4: <?php
! 5: if(substr(PHP_OS, 0, 3) == "WIN")
! 6: die("skip Invalid for Windows");
! 7: ?>
! 8:
! 9: --FILE--
! 10: <?php
! 11: /* Prototype: bool copy ( string $source, string $dest );
! 12: Description: Makes a copy of the file source to dest.
! 13: Returns TRUE on success or FALSE on failure.
! 14: */
! 15:
! 16: /* Test copy() function: Trying to create copy of links */
! 17:
! 18: $file_path = dirname(__FILE__);
! 19:
! 20: echo "*** Testing copy() with symlink and hardlink ***\n";
! 21: $file = $file_path."/copy_variation7.tmp";
! 22: $file_handle = fopen($file, "w");
! 23: fwrite( $file_handle, str_repeat(b"Hello World, this is 2007 year ....\n", 100) );
! 24: fclose($file_handle);
! 25:
! 26: $symlink = $file_path."/copy_variation7_symlink.tmp";
! 27: $hardlink = $file_path."/copy_variation7_hardlink.tmp";
! 28:
! 29: symlink($file, $symlink); //creating symlink
! 30: link($file, $hardlink); //creating hardlink
! 31:
! 32: echo "Size of source files => \n";
! 33: var_dump( filesize($file_path."/copy_variation7_symlink.tmp") ); //size of the symlink itself
! 34: clearstatcache();
! 35: var_dump( filesize($file_path."/copy_variation7_hardlink.tmp") ); //size of the file
! 36: clearstatcache();
! 37:
! 38: echo "-- Now applying copy() on source link to create copies --\n";
! 39: echo "-- With symlink --\n";
! 40: var_dump( copy($symlink, $file_path."/copy_copy_variation7_symlink.tmp") );
! 41: var_dump( file_exists($file_path."/copy_copy_variation7_symlink.tmp") );
! 42: var_dump( is_link($file_path."/copy_copy_variation7_symlink.tmp") );
! 43: var_dump( is_file($file_path."/copy_copy_variation7_symlink.tmp") );
! 44: var_dump( filesize($file_path."/copy_copy_variation7_symlink.tmp") );
! 45: clearstatcache();
! 46:
! 47: echo "-- With hardlink --\n";
! 48: var_dump( copy($hardlink, $file_path."/copy_copy_variation7_hardlink.tmp") );
! 49: var_dump( file_exists($file_path."/copy_copy_variation7_hardlink.tmp") );
! 50: var_dump( is_link($file_path."/copy_copy_variation7_hardlink.tmp") );
! 51: var_dump( is_file($file_path."/copy_copy_variation7_hardlink.tmp") );
! 52: var_dump( filesize($file_path."/copy_copy_variation7_hardlink.tmp") );
! 53: clearstatcache();
! 54:
! 55: echo "*** Done ***\n";
! 56: ?>
! 57:
! 58: --CLEAN--
! 59: <?php
! 60: $file_path = dirname(__FILE__);
! 61: unlink($file_path."/copy_copy_variation7_symlink.tmp");
! 62: unlink($file_path."/copy_copy_variation7_hardlink.tmp");
! 63: unlink($file_path."/copy_variation7_symlink.tmp");
! 64: unlink($file_path."/copy_variation7_hardlink.tmp");
! 65: unlink($file_path."/copy_variation7.tmp");
! 66: ?>
! 67:
! 68: --EXPECTF--
! 69: *** Testing copy() with symlink and hardlink ***
! 70: Size of source files =>
! 71: int(%d)
! 72: int(3600)
! 73: -- Now applying copy() on source link to create copies --
! 74: -- With symlink --
! 75: bool(true)
! 76: bool(true)
! 77: bool(false)
! 78: bool(true)
! 79: int(3600)
! 80: -- With hardlink --
! 81: bool(true)
! 82: bool(true)
! 83: bool(false)
! 84: bool(true)
! 85: int(3600)
! 86: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>