copy_variation6-win32.phpt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 Only 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. if( file_exists($dest) ) {
  43. echo "Destination file name is => ";
  44. print($dest);
  45. echo "\n";
  46. echo "Size of source file => ";
  47. var_dump( filesize($src_file_name) );
  48. clearstatcache();
  49. echo "Size of destination file => ";
  50. var_dump( filesize($dest) );
  51. clearstatcache();
  52. unlink("$dest");
  53. }
  54. $count++;
  55. }
  56. unlink($src_file_name);
  57. rmdir($dirname_with_blank);
  58. rmdir($sub_dir);
  59. rmdir($base_dir);
  60. echo "*** Done ***\n";
  61. ?>
  62. --EXPECTF--
  63. *** Test copy() function: copying file across directories ***
  64. Size of source file => int(0)
  65. -- Now applying copy() on source file to create copies --
  66. -- Iteration 1 --
  67. Copy operation => bool(true)
  68. Existence of destination file => bool(true)
  69. Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp
  70. Size of source file => int(0)
  71. Size of destination file => int(0)
  72. -- Iteration 2 --
  73. Copy operation => bool(true)
  74. Existence of destination file => bool(true)
  75. Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
  76. Size of source file => int(0)
  77. Size of destination file => int(0)
  78. -- Iteration 3 --
  79. Copy operation => bool(true)
  80. Existence of destination file => bool(true)
  81. Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
  82. Size of source file => int(0)
  83. Size of destination file => int(0)
  84. -- Iteration 4 --
  85. Copy operation => bool(true)
  86. Existence of destination file => bool(true)
  87. Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp
  88. Size of source file => int(0)
  89. Size of destination file => int(0)
  90. -- Iteration 5 --
  91. Copy operation => bool(true)
  92. Existence of destination file => bool(true)
  93. Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp
  94. Size of source file => int(0)
  95. Size of destination file => int(0)
  96. -- Iteration 6 --
  97. Copy operation => bool(true)
  98. Existence of destination file => bool(true)
  99. Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp
  100. Size of source file => int(0)
  101. Size of destination file => int(0)
  102. -- Iteration 7 --
  103. Copy operation =>
  104. Warning: copy(%s/copy_variation6/copy_variation6_sub///../*): Failed to open stream: No such file or directory in %s on line %d
  105. bool(false)
  106. Existence of destination file => bool(false)
  107. -- Iteration 8 --
  108. Copy operation => bool(true)
  109. Existence of destination file => bool(true)
  110. Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp
  111. Size of source file => int(0)
  112. Size of destination file => int(0)
  113. *** Done ***