copy_variation8.phpt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. --TEST--
  2. Test copy() function: usage variations - copying links across dirs
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) == "WIN")
  6. die("skip Invalid for Windows");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Trying to copy the links across dir paths given in various notations
  11. and dirs having limited access */
  12. echo "*** Testing copy() function: copying links across different directories ***\n";
  13. $file_path = __DIR__;
  14. $base_dir = $file_path."/copy_variation8";
  15. mkdir($base_dir);
  16. $sub_dir = $base_dir."/copy_variation8_sub";
  17. mkdir($sub_dir);
  18. $dirname_with_blank = $sub_dir."/copy variation6";
  19. mkdir($dirname_with_blank);
  20. $file = $file_path."/copy_variation8.tmp";
  21. fclose( fopen($file, "w") );
  22. $symlink = $file_path."/copy_variation8_symlink.tmp";
  23. $hardlink = $file_path."/copy_variation8_hardlink.tmp";
  24. symlink($file, $symlink); //creating symlink
  25. link($file, $hardlink); //creating hardlink
  26. $dests = array(
  27. $base_dir."/copy_copy_variation8.tmp",
  28. $base_dir."/copy_variation8_sub/copy_copy_variation8.tmp",
  29. "$sub_dir/copy_copy_variation8.tmp",
  30. "$sub_dir/../copy_copy_variation8.tmp",
  31. "$sub_dir/../copy_variation8_sub/copy_copy_variation8.tmp",
  32. "$sub_dir/..///../copy_copy_variation8.tmp",
  33. "$sub_dir///../*",
  34. "$dirname_with_blank/copy_copy_variation8.tmp"
  35. );
  36. $count = 1;
  37. foreach($dests as $dest) {
  38. echo "\n-- Iteration $count --\n";
  39. echo "- With symlink -\n";
  40. var_dump( copy($symlink, $dest) );
  41. var_dump( file_exists($dest) );
  42. var_dump( is_link($dest) ); //expected: bool(false)
  43. var_dump( is_file($dest) ); //expected: bool(true)
  44. clearstatcache();
  45. unlink("$dest");
  46. echo "- With hardlink -\n";
  47. var_dump( copy($hardlink, $dest) );
  48. var_dump( file_exists($dest) );
  49. var_dump( is_link($dest) ); //expected: bool(flase)
  50. var_dump( is_file($dest) ); //expected: bool(true)
  51. clearstatcache();
  52. unlink("$dest");
  53. $count++;
  54. }
  55. unlink($symlink);
  56. unlink($hardlink);
  57. unlink($file);
  58. rmdir($dirname_with_blank);
  59. rmdir($sub_dir);
  60. rmdir($base_dir);
  61. echo "*** Done ***\n";
  62. ?>
  63. --EXPECT--
  64. *** Testing copy() function: copying links across different directories ***
  65. -- Iteration 1 --
  66. - With symlink -
  67. bool(true)
  68. bool(true)
  69. bool(false)
  70. bool(true)
  71. - With hardlink -
  72. bool(true)
  73. bool(true)
  74. bool(false)
  75. bool(true)
  76. -- Iteration 2 --
  77. - With symlink -
  78. bool(true)
  79. bool(true)
  80. bool(false)
  81. bool(true)
  82. - With hardlink -
  83. bool(true)
  84. bool(true)
  85. bool(false)
  86. bool(true)
  87. -- Iteration 3 --
  88. - With symlink -
  89. bool(true)
  90. bool(true)
  91. bool(false)
  92. bool(true)
  93. - With hardlink -
  94. bool(true)
  95. bool(true)
  96. bool(false)
  97. bool(true)
  98. -- Iteration 4 --
  99. - With symlink -
  100. bool(true)
  101. bool(true)
  102. bool(false)
  103. bool(true)
  104. - With hardlink -
  105. bool(true)
  106. bool(true)
  107. bool(false)
  108. bool(true)
  109. -- Iteration 5 --
  110. - With symlink -
  111. bool(true)
  112. bool(true)
  113. bool(false)
  114. bool(true)
  115. - With hardlink -
  116. bool(true)
  117. bool(true)
  118. bool(false)
  119. bool(true)
  120. -- Iteration 6 --
  121. - With symlink -
  122. bool(true)
  123. bool(true)
  124. bool(false)
  125. bool(true)
  126. - With hardlink -
  127. bool(true)
  128. bool(true)
  129. bool(false)
  130. bool(true)
  131. -- Iteration 7 --
  132. - With symlink -
  133. bool(true)
  134. bool(true)
  135. bool(false)
  136. bool(true)
  137. - With hardlink -
  138. bool(true)
  139. bool(true)
  140. bool(false)
  141. bool(true)
  142. -- Iteration 8 --
  143. - With symlink -
  144. bool(true)
  145. bool(true)
  146. bool(false)
  147. bool(true)
  148. - With hardlink -
  149. bool(true)
  150. bool(true)
  151. bool(false)
  152. bool(true)
  153. *** Done ***