copy_variation5-win32.phpt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. /* Prototype: bool copy ( string $source, string $dest );
  11. Description: Makes a copy of the file source to dest.
  12. Returns TRUE on success or FALSE on failure.
  13. */
  14. /* Test copy() function: Checking case sensitivity in creation of destination file names
  15. and the existence and size of destination files
  16. */
  17. echo "*** Test copy() function: checking case sensitivity in creation of destination file names ***\n";
  18. $file_path = dirname(__FILE__);
  19. $src_file_name = $file_path."/copy_variation5.tmp";
  20. $file_handle = fopen($src_file_name, "w");
  21. fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
  22. fclose($file_handle);
  23. /* array of destination file names */
  24. $dest_files = array(
  25. /* Checking case sensitiveness */
  26. "COPY.tmp",
  27. "COPY.TMP",
  28. "CopY.TMP"
  29. );
  30. echo "Size of the source file before copy operation => ";
  31. var_dump( filesize($src_file_name) );
  32. clearstatcache();
  33. echo "\n-- Now applying copy() on source file to create copies --";
  34. $count = 1;
  35. foreach($dest_files as $dest_file) {
  36. echo "\n-- Iteration $count --\n";
  37. $dest_file_name = $file_path."/$dest_file";
  38. echo "Copy operation => ";
  39. var_dump( copy($src_file_name, $dest_file_name) );
  40. echo "Existence of destination file => ";
  41. var_dump( 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. $count++;
  52. }
  53. $count = 1;
  54. foreach($dest_files as $dest_file) {
  55. unlink($file_path."/".$dest_file);
  56. $count++;
  57. }
  58. echo "*** Done ***\n";
  59. ?>
  60. --CLEAN--
  61. <?php
  62. unlink(dirname(__FILE__)."/copy_variation5.tmp");
  63. ?>
  64. --EXPECTF--
  65. *** Test copy() function: checking case sensitivity in creation of destination file names ***
  66. Size of the source file before copy operation => int(1500)
  67. -- Now applying copy() on source file to create copies --
  68. -- Iteration 1 --
  69. Copy operation => bool(true)
  70. Existence of destination file => bool(true)
  71. Destination file name => %s/COPY.tmp
  72. Size of source file => int(1500)
  73. Size of destination file => int(1500)
  74. -- Iteration 2 --
  75. Copy operation => bool(true)
  76. Existence of destination file => bool(true)
  77. Destination file name => %s/COPY.TMP
  78. Size of source file => int(1500)
  79. Size of destination file => int(1500)
  80. -- Iteration 3 --
  81. Copy operation => bool(true)
  82. Existence of destination file => bool(true)
  83. Destination file name => %s/CopY.TMP
  84. Size of source file => int(1500)
  85. Size of destination file => int(1500)
  86. Warning: unlink(%s/COPY.TMP): No such file or directory in %s on line %d
  87. Warning: unlink(%s/CopY.TMP): No such file or directory in %s on line %d
  88. *** Done ***