copy_variation2.phpt 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. --TEST--
  2. Test copy() function: usage variations - destination file names(special chars)
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) == "WIN")
  6. die("skip do not run on Windows");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Test copy() function: In creation of destination file names containing special characters
  11. and checking the existence and size of destination files
  12. */
  13. echo "*** Test copy() function: destination file names containing special characters ***\n";
  14. $file_path = __DIR__;
  15. $src_file_name = $file_path."/copy_variation2.tmp";
  16. $file_handle = fopen($src_file_name, "w");
  17. fwrite( $file_handle, str_repeat("Hello2World...\n", 100) );
  18. fclose($file_handle);
  19. /* array of destination file names */
  20. $dest_files = array(
  21. /* File names containing special(non-alpha numeric) characters */
  22. "_copy_variation2.tmp",
  23. "@copy_variation2.tmp",
  24. "#copy_variation2.tmp",
  25. "+copy_variation2.tmp",
  26. "*copy_variation2.tmp",
  27. "?copy_variation2.tmp",
  28. "<copy_variation2.tmp",
  29. ">copy_variation2.tmp",
  30. "!copy_variation2.tmp",
  31. "&copy_variation2.tmp",
  32. "(copy_variation2.tmp",
  33. ":copy_variation2.tmp",
  34. ";copy_variation2.tmp",
  35. "=copy_variation2.tmp",
  36. "[copy_variation2.tmp",
  37. "^copy_variation2.tmp",
  38. "{copy_variation2.tmp",
  39. "|copy_variation2.tmp",
  40. "~copy_variation2.tmp",
  41. "\$copy_variation2.tmp"
  42. );
  43. echo "Size of the source file before copy operation => ";
  44. var_dump( filesize("$src_file_name") );
  45. clearstatcache();
  46. echo "\n--- Now applying copy() on source file to create copies ---";
  47. $count = 1;
  48. foreach($dest_files as $dest_file) {
  49. echo "\n-- Iteration $count --\n";
  50. $dest_file_name = $file_path."/$dest_file";
  51. echo "Copy operation => ";
  52. var_dump( copy($src_file_name, $dest_file_name) );
  53. echo "Existence of destination file => ";
  54. var_dump( file_exists($dest_file_name) );
  55. echo "Destination file name => ";
  56. print($dest_file_name);
  57. echo "\n";
  58. echo "Size of source file => ";
  59. var_dump( filesize($src_file_name) );
  60. clearstatcache();
  61. echo "Size of destination file => ";
  62. var_dump( filesize($dest_file_name) );
  63. clearstatcache();
  64. unlink($dest_file_name);
  65. $count++;
  66. }
  67. echo "*** Done ***\n";
  68. ?>
  69. --CLEAN--
  70. <?php
  71. unlink(__DIR__."/copy_variation2.tmp");
  72. ?>
  73. --EXPECTF--
  74. *** Test copy() function: destination file names containing special characters ***
  75. Size of the source file before copy operation => int(1500)
  76. --- Now applying copy() on source file to create copies ---
  77. -- Iteration 1 --
  78. Copy operation => bool(true)
  79. Existence of destination file => bool(true)
  80. Destination file name => %s/_copy_variation2.tmp
  81. Size of source file => int(1500)
  82. Size of destination file => int(1500)
  83. -- Iteration 2 --
  84. Copy operation => bool(true)
  85. Existence of destination file => bool(true)
  86. Destination file name => %s/@copy_variation2.tmp
  87. Size of source file => int(1500)
  88. Size of destination file => int(1500)
  89. -- Iteration 3 --
  90. Copy operation => bool(true)
  91. Existence of destination file => bool(true)
  92. Destination file name => %s/#copy_variation2.tmp
  93. Size of source file => int(1500)
  94. Size of destination file => int(1500)
  95. -- Iteration 4 --
  96. Copy operation => bool(true)
  97. Existence of destination file => bool(true)
  98. Destination file name => %s/+copy_variation2.tmp
  99. Size of source file => int(1500)
  100. Size of destination file => int(1500)
  101. -- Iteration 5 --
  102. Copy operation => bool(true)
  103. Existence of destination file => bool(true)
  104. Destination file name => %s/*copy_variation2.tmp
  105. Size of source file => int(1500)
  106. Size of destination file => int(1500)
  107. -- Iteration 6 --
  108. Copy operation => bool(true)
  109. Existence of destination file => bool(true)
  110. Destination file name => %s/?copy_variation2.tmp
  111. Size of source file => int(1500)
  112. Size of destination file => int(1500)
  113. -- Iteration 7 --
  114. Copy operation => bool(true)
  115. Existence of destination file => bool(true)
  116. Destination file name => %s/<copy_variation2.tmp
  117. Size of source file => int(1500)
  118. Size of destination file => int(1500)
  119. -- Iteration 8 --
  120. Copy operation => bool(true)
  121. Existence of destination file => bool(true)
  122. Destination file name => %s/>copy_variation2.tmp
  123. Size of source file => int(1500)
  124. Size of destination file => int(1500)
  125. -- Iteration 9 --
  126. Copy operation => bool(true)
  127. Existence of destination file => bool(true)
  128. Destination file name => %s/!copy_variation2.tmp
  129. Size of source file => int(1500)
  130. Size of destination file => int(1500)
  131. -- Iteration 10 --
  132. Copy operation => bool(true)
  133. Existence of destination file => bool(true)
  134. Destination file name => %s/&copy_variation2.tmp
  135. Size of source file => int(1500)
  136. Size of destination file => int(1500)
  137. -- Iteration 11 --
  138. Copy operation => bool(true)
  139. Existence of destination file => bool(true)
  140. Destination file name => %s/(copy_variation2.tmp
  141. Size of source file => int(1500)
  142. Size of destination file => int(1500)
  143. -- Iteration 12 --
  144. Copy operation => bool(true)
  145. Existence of destination file => bool(true)
  146. Destination file name => %s/:copy_variation2.tmp
  147. Size of source file => int(1500)
  148. Size of destination file => int(1500)
  149. -- Iteration 13 --
  150. Copy operation => bool(true)
  151. Existence of destination file => bool(true)
  152. Destination file name => %s/;copy_variation2.tmp
  153. Size of source file => int(1500)
  154. Size of destination file => int(1500)
  155. -- Iteration 14 --
  156. Copy operation => bool(true)
  157. Existence of destination file => bool(true)
  158. Destination file name => %s/=copy_variation2.tmp
  159. Size of source file => int(1500)
  160. Size of destination file => int(1500)
  161. -- Iteration 15 --
  162. Copy operation => bool(true)
  163. Existence of destination file => bool(true)
  164. Destination file name => %s/[copy_variation2.tmp
  165. Size of source file => int(1500)
  166. Size of destination file => int(1500)
  167. -- Iteration 16 --
  168. Copy operation => bool(true)
  169. Existence of destination file => bool(true)
  170. Destination file name => %s/^copy_variation2.tmp
  171. Size of source file => int(1500)
  172. Size of destination file => int(1500)
  173. -- Iteration 17 --
  174. Copy operation => bool(true)
  175. Existence of destination file => bool(true)
  176. Destination file name => %s/{copy_variation2.tmp
  177. Size of source file => int(1500)
  178. Size of destination file => int(1500)
  179. -- Iteration 18 --
  180. Copy operation => bool(true)
  181. Existence of destination file => bool(true)
  182. Destination file name => %s/|copy_variation2.tmp
  183. Size of source file => int(1500)
  184. Size of destination file => int(1500)
  185. -- Iteration 19 --
  186. Copy operation => bool(true)
  187. Existence of destination file => bool(true)
  188. Destination file name => %s/~copy_variation2.tmp
  189. Size of source file => int(1500)
  190. Size of destination file => int(1500)
  191. -- Iteration 20 --
  192. Copy operation => bool(true)
  193. Existence of destination file => bool(true)
  194. Destination file name => %s/$copy_variation2.tmp
  195. Size of source file => int(1500)
  196. Size of destination file => int(1500)
  197. *** Done ***