copy_variation5.phpt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. --TEST--
  2. Test copy() function: usage variations - destination file names(case sensitive)
  3. --SKIPIF--
  4. <?php
  5. if (file_exists(__DIR__ . '/COPY_VARIATION5.PHPT')) die('skip requires case-sensitive file system');
  6. ?>
  7. --FILE--
  8. <?php
  9. /* Test copy() function: Checking case sensitivity in creation of destination file names
  10. and the existence and size of destination files
  11. */
  12. echo "*** Test copy() function: checking case sensitivity in creation of destination file names ***\n";
  13. $file_path = __DIR__;
  14. $src_file_name = $file_path."/copy_variation5.tmp";
  15. $file_handle = fopen($src_file_name, "w");
  16. fwrite( $file_handle, str_repeat("Hello2World...\n", 100) );
  17. fclose($file_handle);
  18. /* array of destination file names */
  19. $dest_files = array(
  20. /* Checking case sensitiveness */
  21. "COPY.tmp",
  22. "COPY.TMP",
  23. "CopY.TMP"
  24. );
  25. echo "Size of the source file before copy operation => ";
  26. var_dump( filesize($src_file_name) );
  27. clearstatcache();
  28. echo "\n-- Now applying copy() on source file to create copies --";
  29. $count = 1;
  30. foreach($dest_files as $dest_file) {
  31. echo "\n-- Iteration $count --\n";
  32. $dest_file_name = $file_path."/$dest_file";
  33. echo "Copy operation => ";
  34. var_dump( copy($src_file_name, $dest_file_name) );
  35. echo "Existence of destination file => ";
  36. var_dump( file_exists($dest_file_name) );
  37. echo "Destination file name => ";
  38. print($dest_file_name);
  39. echo "\n";
  40. echo "Size of source file => ";
  41. var_dump( filesize($src_file_name) );
  42. clearstatcache();
  43. echo "Size of destination file => ";
  44. var_dump( filesize($dest_file_name) );
  45. clearstatcache();
  46. $count++;
  47. }
  48. $count = 1;
  49. foreach($dest_files as $dest_file) {
  50. unlink($file_path."/".$dest_file);
  51. $count++;
  52. }
  53. echo "*** Done ***\n";
  54. ?>
  55. --CLEAN--
  56. <?php
  57. unlink(__DIR__."/copy_variation5.tmp");
  58. ?>
  59. --EXPECTF--
  60. *** Test copy() function: checking case sensitivity in creation of destination file names ***
  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 => %s/COPY.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 => %s/COPY.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 => %s/CopY.TMP
  79. Size of source file => int(1500)
  80. Size of destination file => int(1500)
  81. *** Done ***