copy_variation3-win32.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 only 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. if( file_exists($dest_file_name) ) {
  42. echo "Destination file name => ";
  43. print($dest_file_name);
  44. echo "\n";
  45. echo "Size of source file => ";
  46. var_dump( filesize($src_file_name) );
  47. clearstatcache();
  48. echo "Size of destination file => ";
  49. var_dump( filesize($dest_file_name) );
  50. clearstatcache();
  51. unlink($dest_file_name);
  52. }
  53. $count++;
  54. }
  55. echo "*** Done ***\n";
  56. ?>
  57. --CLEAN--
  58. <?php
  59. unlink(__DIR__."/copy_variation3.tmp");
  60. ?>
  61. --EXPECTF--
  62. *** Test copy() function: destination file names containing whitespaces ***
  63. Size of the source file before copy operation => int(1500)
  64. -- Now applying copy() on source file to create copies --
  65. -- Iteration 1 --
  66. Copy operation => bool(true)
  67. Existence of destination file => bool(true)
  68. Destination file name => copy variation3.tmp
  69. Size of source file => int(1500)
  70. Size of destination file => int(1500)
  71. -- Iteration 2 --
  72. Copy operation => bool(true)
  73. Existence of destination file => bool(true)
  74. Destination file name => copy_variation3.tmp
  75. Size of source file => int(1500)
  76. Size of destination file => int(1500)
  77. -- Iteration 3 --
  78. Copy operation =>
  79. Warning: copy(%s): %s
  80. bool(false)
  81. Existence of destination file => bool(false)
  82. -- Iteration 4 --
  83. Copy operation =>
  84. Warning: copy(%s): %s
  85. bool(false)
  86. Existence of destination file => bool(false)
  87. *** Done ***