From 40f54b6c21f11ba4a3607e38b555f67547f9795e Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Fri, 10 Aug 2007 02:57:30 +0000 Subject: [PATCH] More new testcases for copy() function --- ext/standard/tests/file/copy_variation1.phpt | 145 +++++++++++ ext/standard/tests/file/copy_variation10.phpt | 37 +++ ext/standard/tests/file/copy_variation11.phpt | 71 ++++++ .../tests/file/copy_variation12-win32.phpt | 47 ++++ ext/standard/tests/file/copy_variation12.phpt | 48 ++++ ext/standard/tests/file/copy_variation13.phpt | 57 +++++ ext/standard/tests/file/copy_variation14.phpt | 48 ++++ ext/standard/tests/file/copy_variation15.phpt | 55 ++++ .../tests/file/copy_variation16-win32.phpt | 144 +++++++++++ ext/standard/tests/file/copy_variation16.phpt | 143 +++++++++++ ext/standard/tests/file/copy_variation17.phpt | 76 ++++++ ext/standard/tests/file/copy_variation18.phpt | 51 ++++ .../tests/file/copy_variation2-win32.phpt | 225 +++++++++++++++++ ext/standard/tests/file/copy_variation2.phpt | 237 ++++++++++++++++++ .../tests/file/copy_variation3-win32.phpt | 109 ++++++++ ext/standard/tests/file/copy_variation3.phpt | 110 ++++++++ .../tests/file/copy_variation4-win32.phpt | Bin 0 -> 4276 bytes ext/standard/tests/file/copy_variation4.phpt | Bin 0 -> 4835 bytes .../tests/file/copy_variation5-win32.phpt | 111 ++++++++ ext/standard/tests/file/copy_variation5.phpt | 107 ++++++++ .../tests/file/copy_variation6-win32.phpt | 143 +++++++++++ ext/standard/tests/file/copy_variation6.phpt | 142 +++++++++++ ext/standard/tests/file/copy_variation7.phpt | 86 +++++++ ext/standard/tests/file/copy_variation8.phpt | 176 +++++++++++++ ext/standard/tests/file/copy_variation9.phpt | 66 +++++ 25 files changed, 2434 insertions(+) create mode 100644 ext/standard/tests/file/copy_variation1.phpt create mode 100644 ext/standard/tests/file/copy_variation10.phpt create mode 100644 ext/standard/tests/file/copy_variation11.phpt create mode 100644 ext/standard/tests/file/copy_variation12-win32.phpt create mode 100644 ext/standard/tests/file/copy_variation12.phpt create mode 100644 ext/standard/tests/file/copy_variation13.phpt create mode 100644 ext/standard/tests/file/copy_variation14.phpt create mode 100644 ext/standard/tests/file/copy_variation15.phpt create mode 100644 ext/standard/tests/file/copy_variation16-win32.phpt create mode 100644 ext/standard/tests/file/copy_variation16.phpt create mode 100644 ext/standard/tests/file/copy_variation17.phpt create mode 100644 ext/standard/tests/file/copy_variation18.phpt create mode 100644 ext/standard/tests/file/copy_variation2-win32.phpt create mode 100644 ext/standard/tests/file/copy_variation2.phpt create mode 100644 ext/standard/tests/file/copy_variation3-win32.phpt create mode 100644 ext/standard/tests/file/copy_variation3.phpt create mode 100644 ext/standard/tests/file/copy_variation4-win32.phpt create mode 100644 ext/standard/tests/file/copy_variation4.phpt create mode 100644 ext/standard/tests/file/copy_variation5-win32.phpt create mode 100644 ext/standard/tests/file/copy_variation5.phpt create mode 100644 ext/standard/tests/file/copy_variation6-win32.phpt create mode 100644 ext/standard/tests/file/copy_variation6.phpt create mode 100644 ext/standard/tests/file/copy_variation7.phpt create mode 100644 ext/standard/tests/file/copy_variation8.phpt create mode 100644 ext/standard/tests/file/copy_variation9.phpt diff --git a/ext/standard/tests/file/copy_variation1.phpt b/ext/standard/tests/file/copy_variation1.phpt new file mode 100644 index 0000000000..7cf20fd749 --- /dev/null +++ b/ext/standard/tests/file/copy_variation1.phpt @@ -0,0 +1,145 @@ +--TEST-- +Test copy() function: usage variations - destination file names(numerics/strings) +--FILE-- + "; +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-- + + +--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 *** diff --git a/ext/standard/tests/file/copy_variation10.phpt b/ext/standard/tests/file/copy_variation10.phpt new file mode 100644 index 0000000000..c5cbc84254 --- /dev/null +++ b/ext/standard/tests/file/copy_variation10.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test copy() function: usage variations - identical names +--FILE-- + + +--CLEAN-- + + +--EXPECTF-- +*** 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..b01dab0890 --- /dev/null +++ b/ext/standard/tests/file/copy_variation11.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test copy() function: usage variations - existing dir as destination +--FILE-- + "; +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-- + + +--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 *** 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..7696769049 --- /dev/null +++ b/ext/standard/tests/file/copy_variation12-win32.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test copy() function: usage variations - dir as source +--SKIPIF-- + +--FILE-- + + +--CLEAN-- + + +--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 *** diff --git a/ext/standard/tests/file/copy_variation12.phpt b/ext/standard/tests/file/copy_variation12.phpt new file mode 100644 index 0000000000..32a45311a2 --- /dev/null +++ b/ext/standard/tests/file/copy_variation12.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test copy() function: usage variations - dir as source (Bug #42111) +--SKIPIF-- + + +--FILE-- + + +--CLEAN-- + + +--EXPECTF-- +*** 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..7ca16c270a --- /dev/null +++ b/ext/standard/tests/file/copy_variation13.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test copy() function: usage variations - src as dir and dest as an existing file(Bug #42243) +--FILE-- + + +--CLEAN-- + + +--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 *** diff --git a/ext/standard/tests/file/copy_variation14.phpt b/ext/standard/tests/file/copy_variation14.phpt new file mode 100644 index 0000000000..6eb8fe3ee4 --- /dev/null +++ b/ext/standard/tests/file/copy_variation14.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test copy() function: usage variations - non existing src/dest +--FILE-- + + +--CLEAN-- + + +--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 *** diff --git a/ext/standard/tests/file/copy_variation15.phpt b/ext/standard/tests/file/copy_variation15.phpt new file mode 100644 index 0000000000..f3eb6ea04e --- /dev/null +++ b/ext/standard/tests/file/copy_variation15.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test copy() function: usage variations - destination dir access perms +--SKIPIF-- + +--FILE-- + + +--CLEAN-- + + +--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 *** 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..b206968f0c --- /dev/null +++ b/ext/standard/tests/file/copy_variation16-win32.phpt @@ -0,0 +1,144 @@ +--TEST-- +Test copy() function: usage variations - copy data file across dirs +--SKIPIF-- + +--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 *** diff --git a/ext/standard/tests/file/copy_variation16.phpt b/ext/standard/tests/file/copy_variation16.phpt new file mode 100644 index 0000000000..9ad834bdb4 --- /dev/null +++ b/ext/standard/tests/file/copy_variation16.phpt @@ -0,0 +1,143 @@ +--TEST-- +Test copy() function: usage variations - copy data file across dirs +--SKIPIF-- + +--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 *** diff --git a/ext/standard/tests/file/copy_variation17.phpt b/ext/standard/tests/file/copy_variation17.phpt new file mode 100644 index 0000000000..2dfe94c6e9 --- /dev/null +++ b/ext/standard/tests/file/copy_variation17.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test copy() function: usage variations - wildcard chars in source +--FILE-- + + +--CLEAN-- + + +--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 *** diff --git a/ext/standard/tests/file/copy_variation18.phpt b/ext/standard/tests/file/copy_variation18.phpt new file mode 100644 index 0000000000..18407bd584 --- /dev/null +++ b/ext/standard/tests/file/copy_variation18.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test copy() function: usage variations - stat after copy +--FILE-- + "; +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-- + + +--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 *** 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..f51cbaf078 --- /dev/null +++ b/ext/standard/tests/file/copy_variation2-win32.phpt @@ -0,0 +1,225 @@ +--TEST-- +Test copy() function: usage variations - destination file names(special chars) +--SKIPIF-- + +--FILE-- +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-- + + +--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 => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- 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/©_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/(copy_variation2.tmp +Size of source file => int(1500) +Size of destination file => int(1500) + +-- Iteration 11 -- +Copy operation => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- 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 => +Warning: copy(%s): %s +bool(false) +Existence of destination file => bool(false) + +-- 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) +*** 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..a9b36803d9 --- /dev/null +++ b/ext/standard/tests/file/copy_variation2.phpt @@ -0,0 +1,237 @@ +--TEST-- +Test copy() function: usage variations - destination file names(special chars) +--SKIPIF-- + +--FILE-- +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-- + + +--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/ 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..a9a445d696 --- /dev/null +++ b/ext/standard/tests/file/copy_variation3-win32.phpt @@ -0,0 +1,109 @@ +--TEST-- +Test copy() function: usage variations - destination file names(white spaces) +--SKIPIF-- + +--FILE-- + "; +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-- + + +--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 *** \ No newline at end of file diff --git a/ext/standard/tests/file/copy_variation3.phpt b/ext/standard/tests/file/copy_variation3.phpt new file mode 100644 index 0000000000..73bf814520 --- /dev/null +++ b/ext/standard/tests/file/copy_variation3.phpt @@ -0,0 +1,110 @@ +--TEST-- +Test copy() function: usage variations - destination file names(white spaces) +--SKIPIF-- + +--FILE-- + "; +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-- + + +--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 *** \ No newline at end of file diff --git a/ext/standard/tests/file/copy_variation4-win32.phpt b/ext/standard/tests/file/copy_variation4-win32.phpt new file mode 100644 index 0000000000000000000000000000000000000000..3c5408aeb0c10b5e10aeb2f59d6effa3453082ad GIT binary patch literal 4276 zcmeHJYj4{&6y0b2iaQ}0q||caJ~kj-S`?{+8uKzEc9DGuATTmj3sFdcq~>|U{`>AF z^{`{v3o@)gv3{{kNxYA9&OKBV&4$xi6nQhQ4J5Ky1tFxRNK7WhDU_Oh;_w?&8KWB- zBADZgnXpSpvz&uq_gn}3zA!7$MrGnt4@8;g8oq;DDRUiqQ8fK&G#OoBo*&;9i^9v& zK$o}pb};!ciGP{);G_pHLiqL!{Oi%BA9?`uj0e8H%L=$E1xS&v@CU9lF_%m2hp)Z2 zZ!qx1XgqAf9v{I(Nh8gw;HNgZZ3%*^FgVb%R0;1jYw89t7682GI#F5S8vmKyaShCE zmnoP9cip-GV59}2Pa6TQxG5E)GrRgYq#|{hBwTBd3NGG_r}kdTvbY5&moMfW#9Q3_CePt`*5Bh-2b2j**cAt&-TjLr?IXc0=DkCZ)!WE?@S| zebK~RU~{O;Ge~8@MX(vD2mX@8lP*#Yrvz=+I(QXJlBn)?7H1mYQ6NY61nF~-w zM0i+D6@~!tu^PNwejJZ`w7fa->1x$Re^QofPJc*}bTz8v9u?_$omSkFt}98~VZP<5 zRJ@XX!Ie|u*&9G~5$5($n8Rj{x|m+a&>;t8p=;R1b`bSi12(zEuSs%_5(iZ91_$erEPM~u z-4@&ta(~@Vsui8w(zd%L%SFuwn(X%J0d;180?!Y#g^Ts)hEK;t9kEvOx`f(zo4D`N zEO~f`Zt3>sxNMo;{!GoJw_J3m0_WJJ$TM-*+5TUoJ}2I1&rpiEZXNo)6dY<}#bXiA z#q;s--DPtyR)M!{c88PV(7GtYUnj%!8J*kz$wA=NI3y+o29m;ZS>ak2U4+ACjS>))MTTmqUHrp!Y!f zEk-rGU9zRO2*#$~N+Wf}nFG?@ISd_l`oML+U#lrMCQF`?irALh1_fJEq lvf^$3Ui04lhr;81dhqX6(;j*4!S%!csB`-Is6TSNzX7rKZNLBk literal 0 HcmV?d00001 diff --git a/ext/standard/tests/file/copy_variation4.phpt b/ext/standard/tests/file/copy_variation4.phpt new file mode 100644 index 0000000000000000000000000000000000000000..e3d479b92fdda634883c3090cb658623449fc1d1 GIT binary patch literal 4835 zcmeHJOK;mo5bl}3Vn8?r>4>uB*eRe?2?AS2getBODR2)4h&8p02-Ca7?y{;{^uK3j z`LsnVsdF(c3*%uCfGL2}Z2DDL$_|gNBr>TaY;abX6`%Vzdf1AuE=a}c$ciAd)lGxMv zHNNf5KFq@3=RG*=!7Cp|BXBP#7q0IBEEDdz`XKi=G@FbMZF<`jcx7p@r)91p-m9OfAHY}uaK?3{lB{U`BfH@mSaDp& zU{<{7w+H}6S}6K-5a1Ixxk7vvpFWSNNS#L!*BYdP^Y_!a{Virmnk(LS_75Bf3+;w{ zA|O({z!%eY!wu`itY8P`P?W{Q5~3B4Zjcq*0skw}hKq;;{iTz?Idmk^wnQGSB)I$g z4^{fu(lFwcaNjt4B%d&2*vSalRwN`Z42jP$L`L?sibDGi{e$l`2m0;-X*H~sdE7U* zSsinQ&7m?!5X+1U?{1(TxN8zmyjF?fUKzDGVr3C3o*@CA`+=vaJi3%BUH1EZthon+ z!$Y6c5=W`j+$$<7&f>4cDpQJWx@%(kC63+#qKj~c%ltO;tP@B*_pr6tL@8%V8)hPg+Vh%}S0V`DLau>jS-K%f zmIH?jV{KVD46S7?V5>;bg+V~nMlu%$0UIFvSRw}Z+DI}D&7%+hV9Q0PHtobzt(0+s zz={xBhr%wMH8HVq&h51TRlp3_g4t@8hHgbs8{A5oZB0~>?!x$x1OYlkSS72%Z_Te= zIcm!`pmrqz@??wzxRgx%@iUNRWbsnGoHIYLSpoZuX#9v?Xl=w##Q0S*Xf zx3cd!lI|rQ4MgABHkotD6ph_sF`i!N1AmC)6eshNwmz*Cx;=1qJA?^c5s(ue8L2jq z2*B6LmhIJqHy*kZpeQ&TpEx$T9nbzZszyP!Dt*vmn6jqfo@W}cE1tHv#w7ICizO0L zcV4Qk=>0!8`TEFm+c0$W%+M2O=+!erKRt1Zj-M%d;tZWUGxWq6di^+t%5A-US7@#0 d-4~GWU*&@zhp@R`H7od+|54|3)2%Ml&R2XcI8p!r literal 0 HcmV?d00001 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..48e85eaf02 --- /dev/null +++ b/ext/standard/tests/file/copy_variation5-win32.phpt @@ -0,0 +1,111 @@ +--TEST-- +Test copy() function: usage variations - destination file names(case sensitive) +--SKIPIF-- + +--FILE-- + "; +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-- + + +--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 *** diff --git a/ext/standard/tests/file/copy_variation5.phpt b/ext/standard/tests/file/copy_variation5.phpt new file mode 100644 index 0000000000..4135dee8a2 --- /dev/null +++ b/ext/standard/tests/file/copy_variation5.phpt @@ -0,0 +1,107 @@ +--TEST-- +Test copy() function: usage variations - destination file names(case sensitive) +--SKIPIF-- + +--FILE-- + "; +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-- + + +--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 *** 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..524b21d377 --- /dev/null +++ b/ext/standard/tests/file/copy_variation6-win32.phpt @@ -0,0 +1,143 @@ +--TEST-- +Test copy() function: usage variations - copy empty file across dirs +--SKIPIF-- + +--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 *** diff --git a/ext/standard/tests/file/copy_variation6.phpt b/ext/standard/tests/file/copy_variation6.phpt new file mode 100644 index 0000000000..1220e34283 --- /dev/null +++ b/ext/standard/tests/file/copy_variation6.phpt @@ -0,0 +1,142 @@ +--TEST-- +Test copy() function: usage variations - copy empty file across dirs +--SKIPIF-- + +--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 *** diff --git a/ext/standard/tests/file/copy_variation7.phpt b/ext/standard/tests/file/copy_variation7.phpt new file mode 100644 index 0000000000..474d33bc49 --- /dev/null +++ b/ext/standard/tests/file/copy_variation7.phpt @@ -0,0 +1,86 @@ +--TEST-- +Test copy() function: usage variations - links +--SKIPIF-- + + +--FILE-- + \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-- + + +--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 *** diff --git a/ext/standard/tests/file/copy_variation8.phpt b/ext/standard/tests/file/copy_variation8.phpt new file mode 100644 index 0000000000..63f57f3a25 --- /dev/null +++ b/ext/standard/tests/file/copy_variation8.phpt @@ -0,0 +1,176 @@ +--TEST-- +Test copy() function: usage variations - copying links across dirs +--SKIPIF-- + +--FILE-- + +--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 *** diff --git a/ext/standard/tests/file/copy_variation9.phpt b/ext/standard/tests/file/copy_variation9.phpt new file mode 100644 index 0000000000..1223c09905 --- /dev/null +++ b/ext/standard/tests/file/copy_variation9.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test copy() function: usage variations - destination file access perms +--SKIPIF-- + + +--FILE-- + + +--CLEAN-- + +--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 *** -- 2.50.1