copy_variation2-win32.phpt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 only 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. );
  41. echo "Size of the source file before copy operation => ";
  42. var_dump( filesize("$src_file_name") );
  43. clearstatcache();
  44. echo "\n--- Now applying copy() on source file to create copies ---";
  45. $count = 1;
  46. foreach($dest_files as $dest_file) {
  47. echo "\n-- Iteration $count --\n";
  48. $dest_file_name = $file_path."/$dest_file";
  49. echo "Copy operation => ";
  50. var_dump( copy($src_file_name, $dest_file_name) );
  51. echo "Existence of destination file => ";
  52. var_dump( file_exists($dest_file_name) );
  53. if( file_exists($dest_file_name) ) {
  54. echo "Destination file name => ";
  55. print($dest_file_name);
  56. echo "\n";
  57. echo "Size of source file => ";
  58. var_dump( filesize($src_file_name) );
  59. clearstatcache();
  60. echo "Size of destination file => ";
  61. var_dump( filesize($dest_file_name) );
  62. clearstatcache();
  63. unlink($dest_file_name);
  64. }
  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 =>
  103. Warning: copy(%s): %s
  104. bool(false)
  105. Existence of destination file => bool(false)
  106. -- Iteration 6 --
  107. Copy operation =>
  108. Warning: copy(%s): %s
  109. bool(false)
  110. Existence of destination file => bool(false)
  111. -- Iteration 7 --
  112. Copy operation => bool(true)
  113. Existence of destination file => bool(true)
  114. Destination file name => %s/!copy_variation2.tmp
  115. Size of source file => int(1500)
  116. Size of destination file => int(1500)
  117. -- Iteration 8 --
  118. Copy operation => bool(true)
  119. Existence of destination file => bool(true)
  120. Destination file name => %s/&copy_variation2.tmp
  121. Size of source file => int(1500)
  122. Size of destination file => int(1500)
  123. -- Iteration 9 --
  124. Copy operation => bool(true)
  125. Existence of destination file => bool(true)
  126. Destination file name => %s/(copy_variation2.tmp
  127. Size of source file => int(1500)
  128. Size of destination file => int(1500)
  129. -- Iteration 10 --
  130. Copy operation =>
  131. Warning: copy(%s): %s
  132. bool(false)
  133. Existence of destination file => bool(false)
  134. -- Iteration 11 --
  135. Copy operation => bool(true)
  136. Existence of destination file => bool(true)
  137. Destination file name => %s/;copy_variation2.tmp
  138. Size of source file => int(1500)
  139. Size of destination file => int(1500)
  140. -- Iteration 12 --
  141. Copy operation => bool(true)
  142. Existence of destination file => bool(true)
  143. Destination file name => %s/=copy_variation2.tmp
  144. Size of source file => int(1500)
  145. Size of destination file => int(1500)
  146. -- Iteration 13 --
  147. Copy operation => bool(true)
  148. Existence of destination file => bool(true)
  149. Destination file name => %s/[copy_variation2.tmp
  150. Size of source file => int(1500)
  151. Size of destination file => int(1500)
  152. -- Iteration 14 --
  153. Copy operation => bool(true)
  154. Existence of destination file => bool(true)
  155. Destination file name => %s/^copy_variation2.tmp
  156. Size of source file => int(1500)
  157. Size of destination file => int(1500)
  158. -- Iteration 15 --
  159. Copy operation => bool(true)
  160. Existence of destination file => bool(true)
  161. Destination file name => %s/{copy_variation2.tmp
  162. Size of source file => int(1500)
  163. Size of destination file => int(1500)
  164. -- Iteration 16 --
  165. Copy operation =>
  166. Warning: copy(%s): %s
  167. bool(false)
  168. Existence of destination file => bool(false)
  169. -- Iteration 17 --
  170. Copy operation => bool(true)
  171. Existence of destination file => bool(true)
  172. Destination file name => %s/~copy_variation2.tmp
  173. Size of source file => int(1500)
  174. Size of destination file => int(1500)
  175. -- Iteration 18 --
  176. Copy operation => bool(true)
  177. Existence of destination file => bool(true)
  178. Destination file name => %s/$copy_variation2.tmp
  179. Size of source file => int(1500)
  180. Size of destination file => int(1500)
  181. *** Done ***