copy_variation6.phpt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. --TEST--
  2. Test copy() function: usage variations - copy empty file across dirs
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) == "WIN")
  6. die("skip Do not run on Windows");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Test copy() function: Trying to create copy of source file
  11. into different destination dir paths given in various notations */
  12. echo "*** Test copy() function: copying file across directories ***\n";
  13. $base_dir = __DIR__."/copy_variation6";
  14. mkdir($base_dir);
  15. $sub_dir = $base_dir."/copy_variation6_sub";
  16. mkdir($sub_dir);
  17. $dirname_with_blank = $sub_dir."/copy variation6";
  18. mkdir($dirname_with_blank);
  19. $src_file_name = __DIR__."/copy_variation6.tmp";
  20. fclose( fopen($src_file_name, "w") );
  21. echo "Size of source file => ";
  22. var_dump( filesize($src_file_name) );
  23. clearstatcache();
  24. $dests = array(
  25. $base_dir."/copy_copy_variation6.tmp",
  26. $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp",
  27. "$sub_dir/copy_copy_variation6.tmp",
  28. "$sub_dir/../copy_copy_variation6.tmp",
  29. "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp",
  30. "$sub_dir/..///../copy_copy_variation6.tmp",
  31. "$sub_dir///../*",
  32. "$dirname_with_blank/copy_copy_variation6.tmp"
  33. );
  34. echo "\n-- Now applying copy() on source file to create copies --";
  35. $count = 1;
  36. foreach($dests as $dest) {
  37. echo "\n-- Iteration $count --\n";
  38. echo "Copy operation => ";
  39. var_dump( copy($src_file_name, $dest) );
  40. echo "Existence of destination file => ";
  41. var_dump( file_exists($dest) );
  42. echo "Destination file name is => ";
  43. print($dest);
  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) );
  50. clearstatcache();
  51. unlink("$dest");
  52. $count++;
  53. }
  54. unlink($src_file_name);
  55. rmdir($dirname_with_blank);
  56. rmdir($sub_dir);
  57. rmdir($base_dir);
  58. echo "*** Done ***\n";
  59. ?>
  60. --EXPECTF--
  61. *** Test copy() function: copying file across directories ***
  62. Size of source file => int(0)
  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 is => %s/copy_variation6/copy_copy_variation6.tmp
  68. Size of source file => int(0)
  69. Size of destination file => int(0)
  70. -- Iteration 2 --
  71. Copy operation => bool(true)
  72. Existence of destination file => bool(true)
  73. Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
  74. Size of source file => int(0)
  75. Size of destination file => int(0)
  76. -- Iteration 3 --
  77. Copy operation => bool(true)
  78. Existence of destination file => bool(true)
  79. Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
  80. Size of source file => int(0)
  81. Size of destination file => int(0)
  82. -- Iteration 4 --
  83. Copy operation => bool(true)
  84. Existence of destination file => bool(true)
  85. Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp
  86. Size of source file => int(0)
  87. Size of destination file => int(0)
  88. -- Iteration 5 --
  89. Copy operation => bool(true)
  90. Existence of destination file => bool(true)
  91. Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp
  92. Size of source file => int(0)
  93. Size of destination file => int(0)
  94. -- Iteration 6 --
  95. Copy operation => bool(true)
  96. Existence of destination file => bool(true)
  97. Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp
  98. Size of source file => int(0)
  99. Size of destination file => int(0)
  100. -- Iteration 7 --
  101. Copy operation => bool(true)
  102. Existence of destination file => bool(true)
  103. Destination file name is => %s/copy_variation6/copy_variation6_sub///../*
  104. Size of source file => int(0)
  105. Size of destination file => int(0)
  106. -- Iteration 8 --
  107. Copy operation => bool(true)
  108. Existence of destination file => bool(true)
  109. Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp
  110. Size of source file => int(0)
  111. Size of destination file => int(0)
  112. *** Done ***