copy_variation5-win32.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. --TEST--
  2. Test copy() function: usage variations - destination file names(case sensitive)
  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: Checking case sensitivity in creation of destination file names
  11. and the existence and size of destination files
  12. */
  13. echo "*** Test copy() function: checking case sensitivity in creation of destination file names ***\n";
  14. $file_path = __DIR__;
  15. $src_file_name = $file_path."/copy_variation5.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. /* Checking case sensitiveness */
  22. "COPY.tmp",
  23. "COPY.TMP",
  24. "CopY.TMP"
  25. );
  26. echo "Size of the source file before copy operation => ";
  27. var_dump( filesize($src_file_name) );
  28. clearstatcache();
  29. echo "\n-- Now applying copy() on source file to create copies --";
  30. $count = 1;
  31. foreach($dest_files as $dest_file) {
  32. echo "\n-- Iteration $count --\n";
  33. $dest_file_name = $file_path."/$dest_file";
  34. echo "Copy operation => ";
  35. var_dump( copy($src_file_name, $dest_file_name) );
  36. echo "Existence of destination file => ";
  37. var_dump( file_exists($dest_file_name) );
  38. echo "Destination file name => ";
  39. print($dest_file_name);
  40. echo "\n";
  41. echo "Size of source file => ";
  42. var_dump( filesize($src_file_name) );
  43. clearstatcache();
  44. echo "Size of destination file => ";
  45. var_dump( filesize($dest_file_name) );
  46. clearstatcache();
  47. $count++;
  48. }
  49. $count = 1;
  50. foreach($dest_files as $dest_file) {
  51. unlink($file_path."/".$dest_file);
  52. $count++;
  53. }
  54. echo "*** Done ***\n";
  55. ?>
  56. --CLEAN--
  57. <?php
  58. unlink(__DIR__."/copy_variation5.tmp");
  59. ?>
  60. --EXPECTF--
  61. *** Test copy() function: checking case sensitivity in creation of destination file names ***
  62. Size of the source file before copy operation => int(1500)
  63. -- Now applying copy() on source file to create copies --
  64. -- Iteration 1 --
  65. Copy operation => bool(true)
  66. Existence of destination file => bool(true)
  67. Destination file name => %s/COPY.tmp
  68. Size of source file => int(1500)
  69. Size of destination file => int(1500)
  70. -- Iteration 2 --
  71. Copy operation => bool(true)
  72. Existence of destination file => bool(true)
  73. Destination file name => %s/COPY.TMP
  74. Size of source file => int(1500)
  75. Size of destination file => int(1500)
  76. -- Iteration 3 --
  77. Copy operation => bool(true)
  78. Existence of destination file => bool(true)
  79. Destination file name => %s/CopY.TMP
  80. Size of source file => int(1500)
  81. Size of destination file => int(1500)
  82. Warning: unlink(%s/COPY.TMP): No such file or directory in %s on line %d
  83. Warning: unlink(%s/CopY.TMP): No such file or directory in %s on line %d
  84. *** Done ***