copy_variation3.phpt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. --TEST--
  2. Test copy() function: usage variations - destination file names(white spaces)
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) == "WIN")
  6. die("skip do not run on Windows");
  7. ?>
  8. --CONFLICTS--
  9. obscure_filename
  10. --FILE--
  11. <?php
  12. /* Test copy() function: In creation of destination file names containing white spaces
  13. and checking the existence and size of destination files
  14. */
  15. echo "*** Test copy() function: destination file names containing whitespaces ***\n";
  16. $file_path = __DIR__;
  17. $src_file_name = $file_path."/copy_variation3.tmp";
  18. $file_handle = fopen($src_file_name, "w");
  19. fwrite( $file_handle, str_repeat("Hello2World...\n", 100) );
  20. fclose($file_handle);
  21. /* array of destination file names */
  22. $dest_files = array(
  23. /* File names containing whitespaces */
  24. "copy variation3.tmp", //file name containing blank space
  25. " copy_variation3.tmp", //file name starts with blank space
  26. "copy\tvariation3.tmp",
  27. " ", //blank space as file name
  28. );
  29. echo "Size of the source file before copy operation => ";
  30. var_dump( filesize("$src_file_name") );
  31. clearstatcache();
  32. echo "\n-- Now applying copy() on source file to create copies --";
  33. $count = 1;
  34. foreach($dest_files as $dest_file) {
  35. echo "\n-- Iteration $count --\n";
  36. $dest_file_name = $dest_file;
  37. echo "Copy operation => ";
  38. var_dump( copy($src_file_name, $dest_file_name) );
  39. echo "Existence of destination file => ";
  40. var_dump( file_exists($dest_file_name) );
  41. echo "Destination file name => ";
  42. print($dest_file_name);
  43. echo "\n";
  44. echo "Size of source file => ";
  45. var_dump( filesize($src_file_name) );
  46. clearstatcache();
  47. echo "Size of destination file => ";
  48. var_dump( filesize($dest_file_name) );
  49. clearstatcache();
  50. unlink($dest_file_name);
  51. $count++;
  52. }
  53. echo "*** Done ***\n";
  54. ?>
  55. --CLEAN--
  56. <?php
  57. unlink(__DIR__."/copy_variation3.tmp");
  58. ?>
  59. --EXPECT--
  60. *** Test copy() function: destination file names containing whitespaces ***
  61. Size of the source file before copy operation => int(1500)
  62. -- Now applying copy() on source file to create copies --
  63. -- Iteration 1 --
  64. Copy operation => bool(true)
  65. Existence of destination file => bool(true)
  66. Destination file name => copy variation3.tmp
  67. Size of source file => int(1500)
  68. Size of destination file => int(1500)
  69. -- Iteration 2 --
  70. Copy operation => bool(true)
  71. Existence of destination file => bool(true)
  72. Destination file name => copy_variation3.tmp
  73. Size of source file => int(1500)
  74. Size of destination file => int(1500)
  75. -- Iteration 3 --
  76. Copy operation => bool(true)
  77. Existence of destination file => bool(true)
  78. Destination file name => copy variation3.tmp
  79. Size of source file => int(1500)
  80. Size of destination file => int(1500)
  81. -- Iteration 4 --
  82. Copy operation => bool(true)
  83. Existence of destination file => bool(true)
  84. Destination file name =>
  85. Size of source file => int(1500)
  86. Size of destination file => int(1500)
  87. *** Done ***