diff options
25 files changed, 3365 insertions, 0 deletions
diff --git a/ext/standard/tests/file/copy_variation1.phpt b/ext/standard/tests/file/copy_variation1.phpt new file mode 100644 index 0000000000..c2d4b1b67a --- /dev/null +++ b/ext/standard/tests/file/copy_variation1.phpt @@ -0,0 +1,213 @@ +--TEST-- +Test copy() function: usage variations - destination file names(numerics/strings) +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: In creation of destination file names containing numerics/strings + and checking the existence and size of destination files +*/ + +echo "*** Test copy() function: destination file names containing numerics/strings ***\n"; +$file_path = dirname(__FILE__); +$src_file_name = $file_path."/copy_variation1.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); +fclose($file_handle); + +/* array of destination file names */ +$dest_files = array( + + /* File names containing numerics, strings */ + "copy.tmp", //regular file name + "copy_copy_variation1.tmp", + ".tmp", //file name only with extension + "123.tmp", //file name starts with numeric and with regular extension + "copy_variation1.123", //file name with numeric extension + "123", //numeric + "123copy_variation1.tmp", //file name containing numeric & string + "copy_variation.tmp123", //file name containing string & numeric + chr(99).chr(111).chr(112).chr(121).chr(49).".tmp" //file name containing ASCII values +); + +echo "Size of the source file before copy operation => "; +var_dump( filesize("$src_file_name") ); +clearstatcache(); + +echo "\n-- Now applying copy() on source file to create copies --"; +$count = 1; +foreach($dest_files as $dest_file) { + echo "\n-- Iteration $count --\n"; + + $dest_file_name = "$file_path/$dest_file"; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest_file_name) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest_file_name) ); + + echo "Destination file name => "; + print($dest_file_name); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest_file_name) ); + clearstatcache(); + + unlink($dest_file_name); + + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation1.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: destination file names containing numerics/strings *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy_copy_variation1.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/123.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy_variation1.123 +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/123 +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/123copy_variation1.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy_variation.tmp123 +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 9 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy1.tmp +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy() function: destination file names containing numerics/strings *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy_copy_variation1.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/123.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy_variation1.123 +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/123 +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/123copy_variation1.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy_variation.tmp123 +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 9 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/copy1.tmp +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation10.phpt b/ext/standard/tests/file/copy_variation10.phpt new file mode 100644 index 0000000000..368e35318d --- /dev/null +++ b/ext/standard/tests/file/copy_variation10.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test copy() function: usage variations - identical names +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Try copying source file to desntination file, where destination file name is identical to source name */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy(): Trying to create a copy of file with the same source name ***\n"; +$file = $file_path."/copy_variation10.tmp"; +$file_handle = fopen($file, "w"); +fwrite($file_handle, str_repeat(b"Hello2world...\n", 100)); +fclose($file_handle); + +var_dump( copy($file, $file) ); +var_dump( file_exists($file) ); +var_dump( filesize($file) ); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation10.tmp"); +?> + +--EXPECTF-- +*** Test copy(): Trying to create a copy of file with the same source name *** +bool(false) +bool(true) +int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy(): Trying to create a copy of file with the same source name *** +bool(false) +bool(true) +int(1500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation11.phpt b/ext/standard/tests/file/copy_variation11.phpt new file mode 100644 index 0000000000..77626f43f8 --- /dev/null +++ b/ext/standard/tests/file/copy_variation11.phpt @@ -0,0 +1,89 @@ +--TEST-- +Test copy() function: usage variations - existing dir as destination +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to copy the file to a destination, where destination is an existing dir */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy() function: Trying to create a copy of source file as a dir ***\n"; +$file = $file_path."/copy_variation11.tmp"; +$file_handle = fopen($file, "w"); +fwrite($file_handle, str_repeat(b"Hello, world...", 20)); +fclose($file_handle); + +$dir = $file_path."/copy_variation11"; +mkdir($dir); + +echo "Size of source before copy operation => "; +var_dump( filesize($file) ); //size of source before copy +clearstatcache(); +echo "Size of destination before copy operation => "; +var_dump( filesize($dir) ); //size of destination before copy +clearstatcache(); + +echo "\n-- Now applying copy() operation --\n"; +var_dump( copy($file, $dir) ); //expected: bool(false) + +var_dump( file_exists($file) ); //expected: bool(true) +var_dump( file_exists($dir) ); //expected: bool(true) + +var_dump( is_file($file) ); //expected: bool(true) +var_dump( is_dir($file) ); //expected: bool(false) + +var_dump( is_file($dir) ); //expected: bool(false) +var_dump( is_dir($dir) ); //expected: bool(true) + +var_dump( filesize($file) ); //size of source after copy +var_dump( filesize($dir) ); //size of destination after copy + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation11.tmp"); +rmdir(dirname(__FILE__)."/copy_variation11"); +?> + +--EXPECTF-- +*** Test copy() function: Trying to create a copy of source file as a dir *** +Size of source before copy operation => int(300) +Size of destination before copy operation => int(%d) + +-- Now applying copy() operation -- + +Warning: %s +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(true) +int(300) +int(%d) +*** Done *** +--UEXPECTF-- +*** Test copy() function: Trying to create a copy of source file as a dir *** +Size of source before copy operation => int(300) +Size of destination before copy operation => int(%d) + +-- Now applying copy() operation -- + +Warning: %s +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(true) +int(300) +int(%d) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation12-win32.phpt b/ext/standard/tests/file/copy_variation12-win32.phpt new file mode 100644 index 0000000000..005984c970 --- /dev/null +++ b/ext/standard/tests/file/copy_variation12-win32.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test copy() function: usage variations - dir as source +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip Run only on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to create a copy of an existing dir */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy() function: Trying to create a copy of an existing dir ***\n"; +$src_dir = $file_path."/copy_variation12"; +mkdir($src_dir); + +$dest = $file_path."/copy_copy_variation12"; + +var_dump( copy($src_dir, $dest) ); + +var_dump( file_exists($dest) ); + +var_dump( filesize($src_dir) ); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_copy_variation12"); +rmdir(dirname(__FILE__)."/copy_variation12"); +?> + +--EXPECTF-- +*** Test copy() function: Trying to create a copy of an existing dir *** + +Warning: copy(%s): failed to open stream: Permission denied in %s on line %d +bool(false) +bool(false) +int(0) +*** Done *** +--UEXPECTF-- +*** Test copy() function: Trying to create a copy of an existing dir *** + +Warning: copy(%s): failed to open stream: Permission denied in %s on line %d +bool(false) +bool(false) +int(0) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation12.phpt b/ext/standard/tests/file/copy_variation12.phpt new file mode 100644 index 0000000000..14f09f2eaf --- /dev/null +++ b/ext/standard/tests/file/copy_variation12.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test copy() function: usage variations - dir as source (Bug #42111) +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Do not run on Windows"); +?> + +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to create a copy of an existing dir */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy() function: Trying to create a copy of an existing dir ***\n"; +$src_dir = $file_path."/copy_variation12"; +mkdir($src_dir); + +$dest = $file_path."/copy_copy_variation12"; + +var_dump( copy($src_dir, $dest) ); + +var_dump( file_exists($dest) ); + +var_dump( filesize($src_dir) ); +var_dump( filesize($dest) ); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_copy_variation12"); +rmdir(dirname(__FILE__)."/copy_variation12"); +?> + +--EXPECTF-- +*** Test copy() function: Trying to create a copy of an existing dir *** +bool(false) +bool(false) +int(4096) +int(0) +*** Done *** +--UEXPECTF-- +*** Test copy() function: Trying to create a copy of an existing dir *** +bool(false) +bool(false) +int(4096) +int(0) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation13.phpt b/ext/standard/tests/file/copy_variation13.phpt new file mode 100644 index 0000000000..fb3fb6374c --- /dev/null +++ b/ext/standard/tests/file/copy_variation13.phpt @@ -0,0 +1,72 @@ +--TEST-- +Test copy() function: usage variations - src as dir and dest as an existing file(Bug #42243) +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to copy dir to an existing file */ + +echo "*** Test copy() function: Trying to copy dir to file ***\n"; +$file_path = dirname(__FILE__); +$file = $file_path."/copy_variation13_dir.tmp"; +fclose(fopen($file, "w")); +$dir = $file_path."/copy_variation13"; +mkdir($dir); + +echo "*** Testing copy() in copying dir to file ***\n"; +var_dump( copy($dir, $file) ); + +var_dump( file_exists($file) ); +var_dump( file_exists($dir) ); + +var_dump( is_file($dir) ); +var_dump( is_dir($dir) ); + +var_dump( is_file($file) ); +var_dump( is_dir($file) ); + +var_dump( filesize($file) ); +var_dump( filesize($dir) ); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation13_dir.tmp"); +rmdir(dirname(__FILE__)."/copy_variation13"); +?> + +--EXPECTF-- +*** Test copy() function: Trying to copy dir to file *** +*** Testing copy() in copying dir to file *** + +Warning: copy(%s): %s +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +int(%d) +int(%d) +*** Done *** +--UEXPECTF-- +*** Test copy() function: Trying to copy dir to file *** +*** Testing copy() in copying dir to file *** + +Warning: copy(%s): %s +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(false) +int(%d) +int(%d) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation14.phpt b/ext/standard/tests/file/copy_variation14.phpt new file mode 100644 index 0000000000..da3410d5a2 --- /dev/null +++ b/ext/standard/tests/file/copy_variation14.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test copy() function: usage variations - non existing src/dest +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to create a copy of non-existing source in an existing destination + and an existing source in non-existing destiantion */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***"; +$file = $file_path."/copy_variation14.tmp"; +$file_handle = fopen($file, "w"); +fwrite($file_handle, str_repeat(b"Hello2world...\n", 100)); +fclose($file_handle); + +var_dump( copy($file_path."/nosuchfile.tmp", $file_path."/copy_nosuchfile.tmp") ); //With non-existing source +var_dump( file_exists($file_path."/copy_nosuchfile.tmp") ); + +echo "\n*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***"; +var_dump( copy($file, $file_path."/nodir/copy_nosuchfile.tmp") ); //With non-existing dir path +var_dump( file_exists($file_path."/nodir/copy_nosuchfile.tmp") ); +var_dump( filesize($file) ); //size of the source + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation14.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: Trying to create a copy of non-existing source in existing destination *** +Warning: copy(%s): %s +bool(false) +bool(false) + +*** Test copy() function: Trying to create copy of an existing source in non-existing destination *** +Warning: copy(%s): %s +bool(false) +bool(false) +int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy() function: Trying to create a copy of non-existing source in existing destination *** +Warning: copy(%s): %s +bool(false) +bool(false) + +*** Test copy() function: Trying to create copy of an existing source in non-existing destination *** +Warning: copy(%s): %s +bool(false) +bool(false) +int(1500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation15.phpt b/ext/standard/tests/file/copy_variation15.phpt new file mode 100644 index 0000000000..0dd3ea2ab4 --- /dev/null +++ b/ext/standard/tests/file/copy_variation15.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test copy() function: usage variations - destination dir access perms +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Invalid for Windows"); +?> + +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to create a copy of file in a dir which doesn't have write permissions */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***"; +$file = $file_path."/copy_variation15.tmp"; +$file_handle = fopen($file, "w"); +fwrite($file_handle, str_repeat(b"Hello, world...", 20)); +fclose($file_handle); + +$dir = $file_path."/copy_variation15"; +mkdir($dir); + +$old_perms = fileperms($dir); + +chmod($dir, 0555); //dir without write permissions + +$dest = $dir."/copy_copy_variation15.tmp"; + +var_dump( copy($file, $dir."/copy_copy_variation15.tmp") ); +var_dump( file_exists($dir."/copy_copy_variation15_dir.tmp") ); +var_dump( filesize($file) ); //size of source + +chmod($dir, $old_perms); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation15.tmp"); +rmdir(dirname(__FILE__)."/copy_variation15"); +?> + +--EXPECTF-- +*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions *** +Warning: copy(%s): %s +bool(false) +bool(false) +int(300) +*** Done *** +--UEXPECTF-- +*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions *** +Warning: copy(%s): %s +bool(false) +bool(false) +int(300) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation16-win32.phpt b/ext/standard/tests/file/copy_variation16-win32.phpt new file mode 100644 index 0000000000..179fc4a402 --- /dev/null +++ b/ext/standard/tests/file/copy_variation16-win32.phpt @@ -0,0 +1,205 @@ +--TEST-- +Test copy() function: usage variations - copy data file across dirs +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip Run only on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: Trying to create copy of source file + into different destination dir paths given in various notations */ + +echo "*** Testing copy() function: copying data file across directories ***\n"; +$base_dir = dirname(__FILE__)."/copy_variation16"; +mkdir($base_dir); + +$sub_dir = $base_dir."/copy_variation16_sub"; +mkdir($sub_dir); + +$dirname_with_blank = $sub_dir."/copy variation6"; +mkdir($dirname_with_blank); + +$src_file_name = dirname(__FILE__)."/copy_variation16.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite($file_handle, str_repeat(b"Hello world, this is 2007 year ...\n", 100)); +fclose($file_handle); + +echo "- Size of source file => "; +var_dump( filesize($src_file_name) ); +clearstatcache(); + +$dests = array( + $base_dir."/copy_copy_variation16.tmp", + $base_dir."/copy_variation16_sub/copy_copy_variation16.tmp", + "$sub_dir/copy_copy_variation16.tmp", + "$sub_dir/../copy_copy_variation16.tmp", + "$sub_dir/../copy_variation16_sub/copy_copy_variation16.tmp", + "$sub_dir/..///../copy_copy_variation16.tmp", + "$sub_dir/..///../*", + "$dirname_with_blank/copy_copy_variation16.tmp" +); + +echo "\n--- Now applying copy() on source file to create copies ---"; +$count = 1; +foreach($dests as $dest) { + echo "\n-- Iteration $count --\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest) ); + + if( file_exists($dest) ){ + echo "Destination file name is => "; + print($dest); + echo "\n"; + + echo "Size of destination file => "; + var_dump( filesize($dest) ); + clearstatcache(); + + unlink("$dest"); + } + $count++; +} + +unlink($src_file_name); +rmdir($dirname_with_blank); +rmdir($sub_dir); +rmdir($base_dir); + +echo "*** Done ***\n"; +?> + +--EXPECTF-- +*** Testing copy() function: copying data file across directories *** +- Size of source file => int(3500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 2 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 3 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 4 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 5 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 6 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 7 -- +Size of source file => int(3500) +Copy operation => +Warning: copy(%s): failed to open stream: No such file or directory in %s on line %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 8 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp +Size of destination file => int(3500) +*** Done *** +--UEXPECTF-- +*** Testing copy() function: copying data file across directories *** +- Size of source file => int(3500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 2 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 3 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 4 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 5 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 6 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 7 -- +Size of source file => int(3500) +Copy operation => +Warning: copy(%s): failed to open stream: No such file or directory in %s on line %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 8 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp +Size of destination file => int(3500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation16.phpt b/ext/standard/tests/file/copy_variation16.phpt new file mode 100644 index 0000000000..13eea405da --- /dev/null +++ b/ext/standard/tests/file/copy_variation16.phpt @@ -0,0 +1,206 @@ +--TEST-- +Test copy() function: usage variations - copy data file across dirs +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Do not run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: Trying to create copy of source file + into different destination dir paths given in various notations */ + +echo "*** Testing copy() function: copying data file across directories ***\n"; +$base_dir = dirname(__FILE__)."/copy_variation16"; +mkdir($base_dir); + +$sub_dir = $base_dir."/copy_variation16_sub"; +mkdir($sub_dir); + +$dirname_with_blank = $sub_dir."/copy variation6"; +mkdir($dirname_with_blank); + +$src_file_name = dirname(__FILE__)."/copy_variation16.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite($file_handle, str_repeat("Hello world, this is 2007 year ...\n", 100)); +fclose($file_handle); + +echo "- Size of source file => "; +var_dump( filesize($src_file_name) ); +clearstatcache(); + +$dests = array( + $base_dir."/copy_copy_variation16.tmp", + $base_dir."/copy_variation16_sub/copy_copy_variation16.tmp", + "$sub_dir/copy_copy_variation16.tmp", + "$sub_dir/../copy_copy_variation16.tmp", + "$sub_dir/../copy_variation16_sub/copy_copy_variation16.tmp", + "$sub_dir/..///../copy_copy_variation16.tmp", + "$sub_dir/..///../*", + "$dirname_with_blank/copy_copy_variation16.tmp" +); + +echo "\n--- Now applying copy() on source file to create copies ---"; +$count = 1; +foreach($dests as $dest) { + echo "\n-- Iteration $count --\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest) ); + + echo "Destination file name is => "; + print($dest); + echo "\n"; + + echo "Size of destination file => "; + var_dump( filesize($dest) ); + clearstatcache(); + + unlink("$dest"); + + $count++; +} + +unlink($src_file_name); +rmdir($dirname_with_blank); +rmdir($sub_dir); +rmdir($base_dir); + +echo "*** Done ***\n"; +?> + +--EXPECTF-- +*** Testing copy() function: copying data file across directories *** +- Size of source file => int(3500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 2 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 3 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 4 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 5 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 6 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 7 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../* +Size of destination file => int(3500) + +-- Iteration 8 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp +Size of destination file => int(3500) +*** Done *** +--UEXPECTF-- +*** Testing copy() function: copying data file across directories *** + +Notice: fwrite(): 3500 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +- Size of source file => int(3500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 2 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 3 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 4 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 5 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 6 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp +Size of destination file => int(3500) + +-- Iteration 7 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../* +Size of destination file => int(3500) + +-- Iteration 8 -- +Size of source file => int(3500) +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp +Size of destination file => int(3500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation17.phpt b/ext/standard/tests/file/copy_variation17.phpt new file mode 100644 index 0000000000..3557e2cd9b --- /dev/null +++ b/ext/standard/tests/file/copy_variation17.phpt @@ -0,0 +1,98 @@ +--TEST-- +Test copy() function: usage variations - wildcard chars in source +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to copy the source file which is given with the combination of wild-card chars */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy() function: With source file names containing wild-card chars ***\n"; +$src_file = $file_path."/copy_variation17.tmp"; +$file_handle = fopen($src_file, "w"); +fwrite($file_handle, str_repeat(b"Hello2world...\n", 100)); +fclose($file_handle); + +$dir = $file_path."/copy_variation17"; +mkdir($dir); + +$src_file_names = array( + $file_path."/copy_variation17.tmp", //without wild-card char + $file_path."/copy*17.tmp", + $file_path."/*_variation17.tmp", + $file_path."/copy_variation*.tmp", + $file_path."/*.tmp" +); + +$dest_file_name = $dir."/copy_copy_variation17.tmp"; + +$count = 1; +foreach($src_file_names as $src_file_name) { + var_dump( copy($src_file_name, $dest_file_name) ); + var_dump( file_exists($dest_file_name) ); + + if( file_exists($dest_file_name) ) { + var_dump( filesize($dest_file_name) ); //size of destination + unlink($dest_file_name); + } + + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation17.tmp"); +rmdir(dirname(__FILE__)."/copy_variation17"); +?> + +--EXPECTF-- +*** Test copy() function: With source file names containing wild-card chars *** +bool(true) +bool(true) +int(1500) + +Warning: copy(%s): %s +bool(false) +bool(false) + +Warning: copy(%s): %s +bool(false) +bool(false) + +Warning: copy(%s): %s +bool(false) +bool(false) + +Warning: copy(%s): %s +bool(false) +bool(false) +*** Done *** +--UEXPECTF-- +*** Test copy() function: With source file names containing wild-card chars *** +bool(true) +bool(true) +int(1500) + +Warning: copy(%s): %s +bool(false) +bool(false) + +Warning: copy(%s): %s +bool(false) +bool(false) + +Warning: copy(%s): %s +bool(false) +bool(false) + +Warning: copy(%s): %s +bool(false) +bool(false) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation18.phpt b/ext/standard/tests/file/copy_variation18.phpt new file mode 100644 index 0000000000..3125ddeef5 --- /dev/null +++ b/ext/standard/tests/file/copy_variation18.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test copy() function: usage variations - stat after copy +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): checking stat of file before and after after copy operation */ + +$file_path = dirname(__FILE__); + +require($file_path."/file.inc"); + +echo "*** Test copy() function: stat of file before and after copy ***\n"; +$src_file_name = $file_path."/copy_variation18.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite($file_handle, str_repeat(b"Hello2world...\n", 100)); +fclose($file_handle); + +$dest_file_name = $file_path."/copy_copy_variation18.tmp"; + +clearstatcache(); + +$stat_before_copy = stat($src_file_name); +clearstatcache(); + +echo "Copy operation => "; +var_dump( copy($src_file_name, $dest_file_name) ); + +$stat_after_copy = stat($src_file_name); +clearstatcache(); + +echo "Comparing the stats of file before and after copy operation => "; +var_dump( compare_stats($stat_before_copy, $stat_after_copy, $all_stat_keys) ); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_copy_variation18.tmp"); +unlink(dirname(__FILE__)."/copy_variation18.tmp"); +?> +--EXPECTF-- +*** Test copy() function: stat of file before and after copy *** +Copy operation => bool(true) +Comparing the stats of file before and after copy operation => bool(true) +*** Done *** +--UEXPECTF-- +*** Test copy() function: stat of file before and after copy *** +Copy operation => bool(true) +Comparing the stats of file before and after copy operation => bool(true) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation2-win32.phpt b/ext/standard/tests/file/copy_variation2-win32.phpt new file mode 100644 index 0000000000..d38e9658c9 --- /dev/null +++ b/ext/standard/tests/file/copy_variation2-win32.phpt @@ -0,0 +1,345 @@ +--TEST-- +Test copy() function: usage variations - destination file names(special chars) +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip only run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: In creation of destination file names containing special characters + and checking the existence and size of destination files +*/ + +echo "*** Test copy() function: destination file names containing special characters ***\n"; +$file_path = dirname(__FILE__); +$src_file_name = $file_path."/copy_variation2.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); +fclose($file_handle); + +/* array of destination file names */ +$dest_files = array( + + /* File names containing special(non-alpha numeric) characters */ + "_copy_variation2.tmp", + "@copy_variation2.tmp", + "#copy_variation2.tmp", + "+copy_variation2.tmp", + "?copy_variation2.tmp", + ">copy_variation2.tmp", + "!copy_variation2.tmp", + "©_variation2.tmp", + "(copy_variation2.tmp", + ":copy_variation2.tmp", + ";copy_variation2.tmp", + "=copy_variation2.tmp", + "[copy_variation2.tmp", + "^copy_variation2.tmp", + "{copy_variation2.tmp", + "|copy_variation2.tmp", + "~copy_variation2.tmp", + "\$copy_variation2.tmp" +); + +echo "Size of the source file before copy operation => "; +var_dump( filesize("$src_file_name") ); +clearstatcache(); + +echo "\n--- Now applying copy() on source file to create copies ---"; +$count = 1; +foreach($dest_files as $dest_file) { + echo "\n-- Iteration $count --\n"; + $dest_file_name = $file_path."/$dest_file"; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest_file_name) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest_file_name) ); + + if( file_exists($dest_file_name) ) { + echo "Destination file name => "; + print($dest_file_name); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest_file_name) ); + clearstatcache(); + + unlink($dest_file_name); + } + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation2.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: destination file names containing special characters *** +Size of the source file before copy operation => int(1500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/_copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/@copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/#copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/+copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 5 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 6 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/!copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/©_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 9 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/(copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 10 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 11 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/;copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 12 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/=copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 13 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/[copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 14 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/^copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 15 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/{copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 16 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 17 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/~copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 18 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/$copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy() function: destination file names containing special characters *** +Size of the source file before copy operation => int(1500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/_copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/@copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/#copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/+copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 5 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 6 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/!copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/©_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 9 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/(copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 10 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 11 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/;copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 12 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/=copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 13 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/[copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 14 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/^copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 15 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/{copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 16 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 17 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/~copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 18 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/$copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done ***
\ No newline at end of file diff --git a/ext/standard/tests/file/copy_variation2.phpt b/ext/standard/tests/file/copy_variation2.phpt new file mode 100644 index 0000000000..2ee60facfb --- /dev/null +++ b/ext/standard/tests/file/copy_variation2.phpt @@ -0,0 +1,382 @@ +--TEST-- +Test copy() function: usage variations - destination file names(special chars) +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip do not run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: In creation of destination file names containing special characters + and checking the existence and size of destination files +*/ + +echo "*** Test copy() function: destination file names containing special characters ***\n"; +$file_path = dirname(__FILE__); +$src_file_name = $file_path."/copy_variation2.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); +fclose($file_handle); + +/* array of destination file names */ +$dest_files = array( + + /* File names containing special(non-alpha numeric) characters */ + "_copy_variation2.tmp", + "@copy_variation2.tmp", + "#copy_variation2.tmp", + "+copy_variation2.tmp", + "*copy_variation2.tmp", + "?copy_variation2.tmp", + "<copy_variation2.tmp", + ">copy_variation2.tmp", + "!copy_variation2.tmp", + "©_variation2.tmp", + "(copy_variation2.tmp", + ":copy_variation2.tmp", + ";copy_variation2.tmp", + "=copy_variation2.tmp", + "[copy_variation2.tmp", + "^copy_variation2.tmp", + "{copy_variation2.tmp", + "|copy_variation2.tmp", + "~copy_variation2.tmp", + "\$copy_variation2.tmp" +); + +echo "Size of the source file before copy operation => "; +var_dump( filesize("$src_file_name") ); +clearstatcache(); + +echo "\n--- Now applying copy() on source file to create copies ---"; +$count = 1; +foreach($dest_files as $dest_file) { + echo "\n-- Iteration $count --\n"; + $dest_file_name = $file_path."/$dest_file"; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest_file_name) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest_file_name) ); + + echo "Destination file name => "; + print($dest_file_name); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest_file_name) ); + clearstatcache(); + + unlink($dest_file_name); + + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation2.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: destination file names containing special characters *** +Size of the source file before copy operation => int(1500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/_copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/@copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/#copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/+copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/*copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/?copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/<copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/>copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 9 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/!copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 10 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/©_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 11 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/(copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 12 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/:copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 13 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/;copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 14 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/=copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 15 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/[copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 16 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/^copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 17 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/{copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 18 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/|copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 19 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/~copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 20 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/$copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy() function: destination file names containing special characters *** +Size of the source file before copy operation => int(1500) + +--- Now applying copy() on source file to create copies --- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/_copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/@copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/#copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/+copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/*copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/?copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/<copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/>copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 9 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/!copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 10 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/©_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 11 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/(copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 12 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/:copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 13 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/;copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 14 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/=copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 15 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/[copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 16 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/^copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 17 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/{copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 18 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/|copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 19 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/~copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 20 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/$copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation3-win32.phpt b/ext/standard/tests/file/copy_variation3-win32.phpt new file mode 100644 index 0000000000..ae6156ea2b --- /dev/null +++ b/ext/standard/tests/file/copy_variation3-win32.phpt @@ -0,0 +1,140 @@ +--TEST-- +Test copy() function: usage variations - destination file names(white spaces) +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip only run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: In creation of destination file names containing white spaces + and checking the existence and size of destination files +*/ + +echo "*** Test copy() function: destination file names containing whitespaces ***\n"; +$file_path = dirname(__FILE__); +$src_file_name = $file_path."/copy_variation3.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); +fclose($file_handle); + +/* array of destination file names */ +$dest_files = array( + + /* File names containing whitespaces */ + "copy variation3.tmp", //file name containing blank space + " copy_variation3.tmp", //file name starts with blank space + "copy\tvariation3.tmp", + " ", //blank space as file name +); + +echo "Size of the source file before copy operation => "; +var_dump( filesize("$src_file_name") ); +clearstatcache(); + +echo "\n-- Now applying copy() on source file to create copies --"; +$count = 1; +foreach($dest_files as $dest_file) { + + echo "\n-- Iteration $count --\n"; + $dest_file_name = $dest_file; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest_file_name) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest_file_name) ); + + if( file_exists($dest_file_name) ) { + echo "Destination file name => "; + print($dest_file_name); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest_file_name) ); + clearstatcache(); + + unlink($dest_file_name); + } + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation3.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: destination file names containing whitespaces *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy_variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 4 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) +*** Done *** +--UEXPECTF-- +*** Test copy() function: destination file names containing whitespaces *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy_variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- Iteration 4 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation3.phpt b/ext/standard/tests/file/copy_variation3.phpt new file mode 100644 index 0000000000..76cc9da74d --- /dev/null +++ b/ext/standard/tests/file/copy_variation3.phpt @@ -0,0 +1,143 @@ +--TEST-- +Test copy() function: usage variations - destination file names(white spaces) +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip do not run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: In creation of destination file names containing white spaces + and checking the existence and size of destination files +*/ + +echo "*** Test copy() function: destination file names containing whitespaces ***\n"; +$file_path = dirname(__FILE__); +$src_file_name = $file_path."/copy_variation3.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); +fclose($file_handle); + +/* array of destination file names */ +$dest_files = array( + + /* File names containing whitespaces */ + "copy variation3.tmp", //file name containing blank space + " copy_variation3.tmp", //file name starts with blank space + "copy\tvariation3.tmp", + " ", //blank space as file name +); + +echo "Size of the source file before copy operation => "; +var_dump( filesize("$src_file_name") ); +clearstatcache(); + +echo "\n-- Now applying copy() on source file to create copies --"; +$count = 1; +foreach($dest_files as $dest_file) { + + echo "\n-- Iteration $count --\n"; + $dest_file_name = $dest_file; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest_file_name) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest_file_name) ); + + echo "Destination file name => "; + print($dest_file_name); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest_file_name) ); + clearstatcache(); + + unlink($dest_file_name); + + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation3.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: destination file names containing whitespaces *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy_variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy() function: destination file names containing whitespaces *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy_variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => copy variation3.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation4-win32.phpt b/ext/standard/tests/file/copy_variation4-win32.phpt Binary files differnew file mode 100644 index 0000000000..be734fb551 --- /dev/null +++ b/ext/standard/tests/file/copy_variation4-win32.phpt diff --git a/ext/standard/tests/file/copy_variation4.phpt b/ext/standard/tests/file/copy_variation4.phpt Binary files differnew file mode 100644 index 0000000000..8e2ca81738 --- /dev/null +++ b/ext/standard/tests/file/copy_variation4.phpt diff --git a/ext/standard/tests/file/copy_variation5-win32.phpt b/ext/standard/tests/file/copy_variation5-win32.phpt new file mode 100644 index 0000000000..9e368c389b --- /dev/null +++ b/ext/standard/tests/file/copy_variation5-win32.phpt @@ -0,0 +1,141 @@ +--TEST-- +Test copy() function: usage variations - destination file names(case sensitive) +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip only run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: Checking case sensitivity in creation of destination file names + and the existence and size of destination files +*/ + +echo "*** Test copy() function: checking case sensitivity in creation of destination file names ***\n"; +$file_path = dirname(__FILE__); +$src_file_name = $file_path."/copy_variation5.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); +fclose($file_handle); + +/* array of destination file names */ +$dest_files = array( + + /* Checking case sensitiveness */ + "COPY.tmp", + "COPY.TMP", + "CopY.TMP" +); + +echo "Size of the source file before copy operation => "; +var_dump( filesize($src_file_name) ); +clearstatcache(); + +echo "\n-- Now applying copy() on source file to create copies --"; +$count = 1; +foreach($dest_files as $dest_file) { + + echo "\n-- Iteration $count --\n"; + $dest_file_name = $file_path."/$dest_file"; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest_file_name) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest_file_name) ); + + echo "Destination file name => "; + print($dest_file_name); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest_file_name) ); + clearstatcache(); + + $count++; +} + + +$count = 1; +foreach($dest_files as $dest_file) { + unlink($file_path."/".$dest_file); + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation5.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: checking case sensitivity in creation of destination file names *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/CopY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) + +Warning: unlink(%s/COPY.TMP): No such file or directory in %s on line %d + +Warning: unlink(%s/CopY.TMP): No such file or directory in %s on line %d +*** Done *** +--UEXPECTF-- +*** Test copy() function: checking case sensitivity in creation of destination file names *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/CopY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) + +Warning: unlink(%s/COPY.TMP): No such file or directory in %s on line %d + +Warning: unlink(%s/CopY.TMP): No such file or directory in %s on line %d +*** Done *** diff --git a/ext/standard/tests/file/copy_variation5.phpt b/ext/standard/tests/file/copy_variation5.phpt new file mode 100644 index 0000000000..c43e7d5f44 --- /dev/null +++ b/ext/standard/tests/file/copy_variation5.phpt @@ -0,0 +1,132 @@ +--TEST-- +Test copy() function: usage variations - destination file names(case sensitive) +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip do not run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: Checking case sensitivity in creation of destination file names + and the existence and size of destination files +*/ + +echo "*** Test copy() function: checking case sensitivity in creation of destination file names ***\n"; +$file_path = dirname(__FILE__); +$src_file_name = $file_path."/copy_variation5.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); +fclose($file_handle); + +/* array of destination file names */ +$dest_files = array( + + /* Checking case sensitiveness */ + "COPY.tmp", + "COPY.TMP", + "CopY.TMP" +); + +echo "Size of the source file before copy operation => "; +var_dump( filesize($src_file_name) ); +clearstatcache(); + +echo "\n-- Now applying copy() on source file to create copies --"; +$count = 1; +foreach($dest_files as $dest_file) { + + echo "\n-- Iteration $count --\n"; + $dest_file_name = $file_path."/$dest_file"; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest_file_name) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest_file_name) ); + + echo "Destination file name => "; + print($dest_file_name); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest_file_name) ); + clearstatcache(); + + $count++; +} + +$count = 1; +foreach($dest_files as $dest_file) { + unlink($file_path."/".$dest_file); + $count++; +} + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_variation5.tmp"); +?> + +--EXPECTF-- +*** Test copy() function: checking case sensitivity in creation of destination file names *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/CopY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy() function: checking case sensitivity in creation of destination file names *** +Size of the source file before copy operation => int(1500) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/COPY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name => %s/CopY.TMP +Size of source file => int(1500) +Size of destination file => int(1500) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation6-win32.phpt b/ext/standard/tests/file/copy_variation6-win32.phpt new file mode 100644 index 0000000000..f7ebbf2850 --- /dev/null +++ b/ext/standard/tests/file/copy_variation6-win32.phpt @@ -0,0 +1,203 @@ +--TEST-- +Test copy() function: usage variations - copy empty file across dirs +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip Only run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: Trying to create copy of source file + into different destination dir paths given in various notations */ + +echo "*** Test copy() function: copying file across directories ***\n"; +$base_dir = dirname(__FILE__)."/copy_variation6"; +mkdir($base_dir); + +$sub_dir = $base_dir."/copy_variation6_sub"; +mkdir($sub_dir); + +$dirname_with_blank = $sub_dir."/copy variation6"; +mkdir($dirname_with_blank); + +$src_file_name = dirname(__FILE__)."/copy_variation6.tmp"; +fclose( fopen($src_file_name, "w") ); + +echo "Size of source file => "; +var_dump( filesize($src_file_name) ); +clearstatcache(); + +$dests = array( + $base_dir."/copy_copy_variation6.tmp", + $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp", + "$sub_dir/copy_copy_variation6.tmp", + "$sub_dir/../copy_copy_variation6.tmp", + "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp", + "$sub_dir/..///../copy_copy_variation6.tmp", + "$sub_dir/..///../*", + "$dirname_with_blank/copy_copy_variation6.tmp" +); + +echo "\n-- Now applying copy() on source file to create copies --"; +$count = 1; +foreach($dests as $dest) { + echo "\n-- Iteration $count --\n"; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest) ); + + if( file_exists($dest) ) { + echo "Destination file name is => "; + print($dest); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest) ); + clearstatcache(); + + unlink("$dest"); + } + + $count++; +} + +unlink($src_file_name); +rmdir($dirname_with_blank); +rmdir($sub_dir); +rmdir($base_dir); + +echo "*** Done ***\n"; +?> + +--EXPECTF-- +*** Test copy() function: copying file across directories *** +Size of source file => int(0) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 7 -- +Copy operation => +Warning: copy(%s/copy_variation6/copy_variation6_sub/..///../*): failed to open stream: No such file or directory in %s on line %d +bool(false) +Existence of destination file => bool(false) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) +*** Done *** +--UEXPECTF-- +*** Test copy() function: copying file across directories *** +Size of source file => int(0) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 7 -- +Copy operation => +Warning: copy(%s/copy_variation6/copy_variation6_sub/..///../*): failed to open stream: No such file or directory in %s on line %d +bool(false) +Existence of destination file => bool(false) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation6.phpt b/ext/standard/tests/file/copy_variation6.phpt new file mode 100644 index 0000000000..41b4069d9a --- /dev/null +++ b/ext/standard/tests/file/copy_variation6.phpt @@ -0,0 +1,203 @@ +--TEST-- +Test copy() function: usage variations - copy empty file across dirs +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Do not run on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: Trying to create copy of source file + into different destination dir paths given in various notations */ + +echo "*** Test copy() function: copying file across directories ***\n"; +$base_dir = dirname(__FILE__)."/copy_variation6"; +mkdir($base_dir); + +$sub_dir = $base_dir."/copy_variation6_sub"; +mkdir($sub_dir); + +$dirname_with_blank = $sub_dir."/copy variation6"; +mkdir($dirname_with_blank); + +$src_file_name = dirname(__FILE__)."/copy_variation6.tmp"; +fclose( fopen($src_file_name, "w") ); + +echo "Size of source file => "; +var_dump( filesize($src_file_name) ); +clearstatcache(); + +$dests = array( + $base_dir."/copy_copy_variation6.tmp", + $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp", + "$sub_dir/copy_copy_variation6.tmp", + "$sub_dir/../copy_copy_variation6.tmp", + "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp", + "$sub_dir/..///../copy_copy_variation6.tmp", + "$sub_dir/..///../*", + "$dirname_with_blank/copy_copy_variation6.tmp" +); + +echo "\n-- Now applying copy() on source file to create copies --"; +$count = 1; +foreach($dests as $dest) { + echo "\n-- Iteration $count --\n"; + + echo "Copy operation => "; + var_dump( copy($src_file_name, $dest) ); + + echo "Existence of destination file => "; + var_dump( file_exists($dest) ); + + echo "Destination file name is => "; + print($dest); + echo "\n"; + + echo "Size of source file => "; + var_dump( filesize($src_file_name) ); + clearstatcache(); + + echo "Size of destination file => "; + var_dump( filesize($dest) ); + clearstatcache(); + + unlink("$dest"); + + $count++; +} + +unlink($src_file_name); +rmdir($dirname_with_blank); +rmdir($sub_dir); +rmdir($base_dir); + +echo "*** Done ***\n"; +?> + +--EXPECTF-- +*** Test copy() function: copying file across directories *** +Size of source file => int(0) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../* +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) +*** Done *** +--UEXPECTF-- +*** Test copy() function: copying file across directories *** +Size of source file => int(0) + +-- Now applying copy() on source file to create copies -- +-- Iteration 1 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 2 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 3 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 4 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 5 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 6 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 7 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../* +Size of source file => int(0) +Size of destination file => int(0) + +-- Iteration 8 -- +Copy operation => bool(true) +Existence of destination file => bool(true) +Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp +Size of source file => int(0) +Size of destination file => int(0) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation7.phpt b/ext/standard/tests/file/copy_variation7.phpt new file mode 100644 index 0000000000..0728949e37 --- /dev/null +++ b/ext/standard/tests/file/copy_variation7.phpt @@ -0,0 +1,105 @@ +--TEST-- +Test copy() function: usage variations - links +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Invalid for Windows"); +?> + +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy() function: Trying to create copy of links */ + +$file_path = dirname(__FILE__); + +echo "*** Testing copy() with symlink and hardlink ***\n"; +$file = $file_path."/copy_variation7.tmp"; +$file_handle = fopen($file, "w"); +fwrite( $file_handle, str_repeat(b"Hello World, this is 2007 year ....\n", 100) ); +fclose($file_handle); + +$symlink = $file_path."/copy_variation7_symlink.tmp"; +$hardlink = $file_path."/copy_variation7_hardlink.tmp"; + +symlink($file, $symlink); //creating symlink +link($file, $hardlink); //creating hardlink + +echo "Size of source files => \n"; +var_dump( filesize($file_path."/copy_variation7_symlink.tmp") ); //size of the symlink itself +clearstatcache(); +var_dump( filesize($file_path."/copy_variation7_hardlink.tmp") ); //size of the file +clearstatcache(); + +echo "-- Now applying copy() on source link to create copies --\n"; +echo "-- With symlink --\n"; +var_dump( copy($symlink, $file_path."/copy_copy_variation7_symlink.tmp") ); +var_dump( file_exists($file_path."/copy_copy_variation7_symlink.tmp") ); +var_dump( is_link($file_path."/copy_copy_variation7_symlink.tmp") ); +var_dump( is_file($file_path."/copy_copy_variation7_symlink.tmp") ); +var_dump( filesize($file_path."/copy_copy_variation7_symlink.tmp") ); +clearstatcache(); + +echo "-- With hardlink --\n"; +var_dump( copy($hardlink, $file_path."/copy_copy_variation7_hardlink.tmp") ); +var_dump( file_exists($file_path."/copy_copy_variation7_hardlink.tmp") ); +var_dump( is_link($file_path."/copy_copy_variation7_hardlink.tmp") ); +var_dump( is_file($file_path."/copy_copy_variation7_hardlink.tmp") ); +var_dump( filesize($file_path."/copy_copy_variation7_hardlink.tmp") ); +clearstatcache(); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink($file_path."/copy_copy_variation7_symlink.tmp"); +unlink($file_path."/copy_copy_variation7_hardlink.tmp"); +unlink($file_path."/copy_variation7_symlink.tmp"); +unlink($file_path."/copy_variation7_hardlink.tmp"); +unlink($file_path."/copy_variation7.tmp"); +?> + +--EXPECTF-- +*** Testing copy() with symlink and hardlink *** +Size of source files => +int(%d) +int(3600) +-- Now applying copy() on source link to create copies -- +-- With symlink -- +bool(true) +bool(true) +bool(false) +bool(true) +int(3600) +-- With hardlink -- +bool(true) +bool(true) +bool(false) +bool(true) +int(3600) +*** Done *** +--UEXPECTF-- +*** Testing copy() with symlink and hardlink *** +Size of source files => +int(%d) +int(3600) +-- Now applying copy() on source link to create copies -- +-- With symlink -- +bool(true) +bool(true) +bool(false) +bool(true) +int(3600) +-- With hardlink -- +bool(true) +bool(true) +bool(false) +bool(true) +int(3600) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation8.phpt b/ext/standard/tests/file/copy_variation8.phpt new file mode 100644 index 0000000000..e7dd9ca5ec --- /dev/null +++ b/ext/standard/tests/file/copy_variation8.phpt @@ -0,0 +1,275 @@ +--TEST-- +Test copy() function: usage variations - copying links across dirs +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Invalid for Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Trying to copy the links across dir paths given in various notations + and dirs having limited access */ + +echo "*** Testing copy() function: copying links across different directories ***\n"; + +$file_path = dirname(__FILE__); + +$base_dir = $file_path."/copy_variation8"; +mkdir($base_dir); +$sub_dir = $base_dir."/copy_variation8_sub"; +mkdir($sub_dir); +$dirname_with_blank = $sub_dir."/copy variation6"; +mkdir($dirname_with_blank); + +$file = $file_path."/copy_variation8.tmp"; +fclose( fopen($file, "w") ); + +$symlink = $file_path."/copy_variation8_symlink.tmp"; +$hardlink = $file_path."/copy_variation8_hardlink.tmp"; + +symlink($file, $symlink); //creating symlink +link($file, $hardlink); //creating hardlink + +$dests = array( + $base_dir."/copy_copy_variation8.tmp", + $base_dir."/copy_variation8_sub/copy_copy_variation8.tmp", + "$sub_dir/copy_copy_variation8.tmp", + "$sub_dir/../copy_copy_variation8.tmp", + "$sub_dir/../copy_variation8_sub/copy_copy_variation8.tmp", + "$sub_dir/..///../copy_copy_variation8.tmp", + "$sub_dir/..///../*", + "$dirname_with_blank/copy_copy_variation8.tmp" +); + +$count = 1; +foreach($dests as $dest) { + echo "\n-- Iteration $count --\n"; + echo "- With symlink -\n"; + var_dump( copy($symlink, $dest) ); + var_dump( file_exists($dest) ); + var_dump( is_link($dest) ); //expected: bool(false) + var_dump( is_file($dest) ); //expected: bool(true) + clearstatcache(); + unlink("$dest"); + echo "- With hardlink -\n"; + var_dump( copy($hardlink, $dest) ); + var_dump( file_exists($dest) ); + var_dump( is_link($dest) ); //expected: bool(flase) + var_dump( is_file($dest) ); //expected: bool(true) + clearstatcache(); + unlink("$dest"); + $count++; +} + +unlink($symlink); +unlink($hardlink); +unlink($file); +rmdir($dirname_with_blank); +rmdir($sub_dir); +rmdir($base_dir); + +echo "*** Done ***\n"; +?> +--EXPECTF-- +*** Testing copy() function: copying links across different directories *** + +-- Iteration 1 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 2 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 3 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 4 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 5 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 6 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 7 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 8 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) +*** Done *** +--UEXPECTF-- +*** Testing copy() function: copying links across different directories *** + +-- Iteration 1 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 2 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 3 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 4 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 5 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 6 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 7 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) + +-- Iteration 8 -- +- With symlink - +bool(true) +bool(true) +bool(false) +bool(true) +- With hardlink - +bool(true) +bool(true) +bool(false) +bool(true) +*** Done *** diff --git a/ext/standard/tests/file/copy_variation9.phpt b/ext/standard/tests/file/copy_variation9.phpt new file mode 100644 index 0000000000..9e405a8ea8 --- /dev/null +++ b/ext/standard/tests/file/copy_variation9.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test copy() function: usage variations - destination file access perms +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Invalid for Windows"); +?> +--FILE-- +<?php +/* Prototype: bool copy ( string $source, string $dest ); + Description: Makes a copy of the file source to dest. + Returns TRUE on success or FALSE on failure. +*/ + +/* Test copy(): Trying to copy source file to destination file with and without write permissions */ + +$file_path = dirname(__FILE__); + +echo "*** Test copy() function: destination with/without write permissions ***\n"; +$src_file_name = $file_path."/copy_variation9.tmp"; +$file_handle = fopen($src_file_name, "w"); +fwrite($file_handle, str_repeat(b"Hello2world...\n", 100)); +fclose($file_handle); + +$dest_file_name = $file_path."/copy_copy_variation9.tmp"; + + +echo "\n-- With write permissions --\n"; +var_dump( file_exists($src_file_name) ); +var_dump( copy($src_file_name, $dest_file_name) ); +var_dump( file_exists($dest_file_name) ); +var_dump( filesize($dest_file_name) ); + +echo "\n-- Without write permissions --\n"; +chmod($file_path."/copy_copy_variation9.tmp", 0555); //No write permissions +var_dump( file_exists($src_file_name) ); +var_dump( copy($src_file_name, $dest_file_name) ); +var_dump( file_exists($dest_file_name) ); +var_dump( filesize($dest_file_name) ); + +echo "*** Done ***\n"; +?> + +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/copy_copy_variation9.tmp"); +unlink(dirname(__FILE__)."/copy_variation9.tmp"); +?> +--EXPECTF-- +*** Test copy() function: destination with/without write permissions *** + +-- With write permissions -- +bool(true) +bool(true) +bool(true) +int(1500) + +-- Without write permissions -- +bool(true) + +Warning: %s +bool(false) +bool(true) +int(1500) +*** Done *** +--UEXPECTF-- +*** Test copy() function: destination with/without write permissions *** + +-- With write permissions -- +bool(true) +bool(true) +bool(true) +int(1500) + +-- Without write permissions -- +bool(true) + +Warning: %s +bool(false) +bool(true) +int(1500) +*** Done *** |