Annotation of embedaddon/php/ext/standard/tests/file/copy_variation4.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test copy() function: usage variations - destination file names(empty string, nulls & bools)
! 3: --SKIPIF--
! 4: <?php
! 5: if(substr(PHP_OS, 0, 3) == "AIX")
! 6: die("skip Do not run on AIX");
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: /* Prototype: bool copy ( string $source, string $dest );
! 11: Description: Makes a copy of the file source to dest.
! 12: Returns TRUE on success or FALSE on failure.
! 13: */
! 14:
! 15: /* Test copy() function: In creation of destination file names with empty string, nulls & bools
! 16: and checking the existence and size of destination files
! 17: */
! 18:
! 19: echo "*** Test copy() function: destination file names with empty string, nulls & bools ***\n";
! 20: $file_path = dirname(__FILE__);
! 21: $src_file_name = $file_path."/copy_variation4.tmp";
! 22: $file_handle = fopen($src_file_name, "wb");
! 23: fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
! 24: fclose($file_handle);
! 25:
! 26: /* array of destination file names */
! 27: $dest_files = array(
! 28:
! 29: /* File names containing(or with) nulls */
! 30: "",
! 31: NULL,
! 32: "\0",
! 33: FALSE,
! 34: false,
! 35: TRUE,
! 36: true
! 37: );
! 38:
! 39: echo "Size of the source file before copy operation => ";
! 40: var_dump( filesize($src_file_name) );
! 41: clearstatcache();
! 42:
! 43: echo "\n-- Now applying copy() on source file to create copies --";
! 44: $count = 1;
! 45: foreach($dest_files as $dest_file) {
! 46: echo "\n-- Iteration $count --\n";
! 47: $dest_file_name = $file_path."/$dest_file";
! 48:
! 49: echo "Existence of destination file before copy => ";
! 50: var_dump( file_exists($dest_file_name) );
! 51:
! 52: echo "Copy operation => ";
! 53: var_dump( copy($src_file_name, $dest_file_name) );
! 54:
! 55: echo "Existence of destination file => ";
! 56: var_dump( file_exists($dest_file_name) );
! 57:
! 58: echo "Destination file name => ";
! 59: print($dest_file_name);
! 60: echo "\n";
! 61:
! 62: echo "Size of source file => ";
! 63: var_dump( filesize($src_file_name) );
! 64: clearstatcache();
! 65:
! 66: echo "Size of destination file => ";
! 67: var_dump( filesize($dest_file_name) );
! 68: clearstatcache();
! 69:
! 70: unlink($dest_file_name);
! 71:
! 72: $count++;
! 73:
! 74: }
! 75:
! 76: echo "*** Done ***\n";
! 77: ?>
! 78:
! 79: --CLEAN--
! 80: <?php
! 81: unlink(dirname(__FILE__)."/copy_variation4.tmp");
! 82: ?>
! 83:
! 84: --EXPECTF--
! 85: *** Test copy() function: destination file names with empty string, nulls & bools ***
! 86: Size of the source file before copy operation => int(1500)
! 87:
! 88: -- Now applying copy() on source file to create copies --
! 89: -- Iteration 1 --
! 90: Existence of destination file before copy => bool(true)
! 91: Copy operation =>
! 92: Warning: copy(): The second argument to copy() function cannot be a directory in %s on line %d
! 93: bool(false)
! 94: Existence of destination file => bool(true)
! 95: Destination file name => %s/
! 96: Size of source file => int(1500)
! 97: Size of destination file => int(%d)
! 98:
! 99: Warning: unlink(%s): %s
! 100:
! 101: -- Iteration 2 --
! 102: Existence of destination file before copy => bool(true)
! 103: Copy operation =>
! 104: Warning: copy(): The second argument to copy() function cannot be a directory in %s on line %d
! 105: bool(false)
! 106: Existence of destination file => bool(true)
! 107: Destination file name => %s/
! 108: Size of source file => int(1500)
! 109: Size of destination file => int(%d)
! 110:
! 111: Warning: unlink(%s): %s
! 112:
! 113: -- Iteration 3 --
! 114: Existence of destination file before copy => bool(false)
! 115: Copy operation => bool(false)
! 116: Existence of destination file => bool(false)
! 117: Destination file name => %s/
! 118: Size of source file => int(1500)
! 119: Size of destination file => bool(false)
! 120:
! 121: -- Iteration 4 --
! 122: Existence of destination file before copy => bool(true)
! 123: Copy operation =>
! 124: Warning: copy(): The second argument to copy() function cannot be a directory in %s on line %d
! 125: bool(false)
! 126: Existence of destination file => bool(true)
! 127: Destination file name => %s/
! 128: Size of source file => int(1500)
! 129: Size of destination file => int(%d)
! 130:
! 131: Warning: unlink(%s): %s
! 132:
! 133: -- Iteration 5 --
! 134: Existence of destination file before copy => bool(true)
! 135: Copy operation =>
! 136: Warning: copy(): The second argument to copy() function cannot be a directory in %s on line %d
! 137: bool(false)
! 138: Existence of destination file => bool(true)
! 139: Destination file name => %s/
! 140: Size of source file => int(1500)
! 141: Size of destination file => int(%d)
! 142:
! 143: Warning: unlink(%s): %s
! 144:
! 145: -- Iteration 6 --
! 146: Existence of destination file before copy => bool(false)
! 147: Copy operation => bool(true)
! 148: Existence of destination file => bool(true)
! 149: Destination file name => %s/1
! 150: Size of source file => int(1500)
! 151: Size of destination file => int(1500)
! 152:
! 153: -- Iteration 7 --
! 154: Existence of destination file before copy => bool(false)
! 155: Copy operation => bool(true)
! 156: Existence of destination file => bool(true)
! 157: Destination file name => %s/1
! 158: Size of source file => int(1500)
! 159: Size of destination file => int(1500)
! 160: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>