copy_variation6-win32.phpt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. /* 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: Trying to create copy of source file
  15. into different destination dir paths given in various notations */
  16. echo "*** Test copy() function: copying file across directories ***\n";
  17. $base_dir = dirname(__FILE__)."/copy_variation6";
  18. mkdir($base_dir);
  19. $sub_dir = $base_dir."/copy_variation6_sub";
  20. mkdir($sub_dir);
  21. $dirname_with_blank = $sub_dir."/copy variation6";
  22. mkdir($dirname_with_blank);
  23. $src_file_name = dirname(__FILE__)."/copy_variation6.tmp";
  24. fclose( fopen($src_file_name, "w") );
  25. echo "Size of source file => ";
  26. var_dump( filesize($src_file_name) );
  27. clearstatcache();
  28. $dests = array(
  29. $base_dir."/copy_copy_variation6.tmp",
  30. $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp",
  31. "$sub_dir/copy_copy_variation6.tmp",
  32. "$sub_dir/../copy_copy_variation6.tmp",
  33. "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp",
  34. "$sub_dir/..///../copy_copy_variation6.tmp",
  35. "$sub_dir/..///../*",
  36. "$dirname_with_blank/copy_copy_variation6.tmp"
  37. );
  38. echo "\n-- Now applying copy() on source file to create copies --";
  39. $count = 1;
  40. foreach($dests as $dest) {
  41. echo "\n-- Iteration $count --\n";
  42. echo "Copy operation => ";
  43. var_dump( copy($src_file_name, $dest) );
  44. echo "Existence of destination file => ";
  45. var_dump( file_exists($dest) );
  46. if( file_exists($dest) ) {
  47. echo "Destination file name is => ";
  48. print($dest);
  49. echo "\n";
  50. echo "Size of source file => ";
  51. var_dump( filesize($src_file_name) );
  52. clearstatcache();
  53. echo "Size of destination file => ";
  54. var_dump( filesize($dest) );
  55. clearstatcache();
  56. unlink("$dest");
  57. }
  58. $count++;
  59. }
  60. unlink($src_file_name);
  61. rmdir($dirname_with_blank);
  62. rmdir($sub_dir);
  63. rmdir($base_dir);
  64. echo "*** Done ***\n";
  65. ?>
  66. --EXPECTF--
  67. *** Test copy() function: copying file across directories ***
  68. Size of source file => int(0)
  69. -- Now applying copy() on source file to create copies --
  70. -- Iteration 1 --
  71. Copy operation => bool(true)
  72. Existence of destination file => bool(true)
  73. Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp
  74. Size of source file => int(0)
  75. Size of destination file => int(0)
  76. -- Iteration 2 --
  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 3 --
  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 4 --
  89. Copy operation => bool(true)
  90. Existence of destination file => bool(true)
  91. Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp
  92. Size of source file => int(0)
  93. Size of destination file => int(0)
  94. -- Iteration 5 --
  95. Copy operation => bool(true)
  96. Existence of destination file => bool(true)
  97. Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp
  98. Size of source file => int(0)
  99. Size of destination file => int(0)
  100. -- Iteration 6 --
  101. Copy operation => bool(true)
  102. Existence of destination file => bool(true)
  103. Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp
  104. Size of source file => int(0)
  105. Size of destination file => int(0)
  106. -- Iteration 7 --
  107. Copy operation =>
  108. Warning: copy(%s/copy_variation6/copy_variation6_sub/..///../*): failed to open stream: No such file or directory in %s on line %d
  109. bool(false)
  110. Existence of destination file => bool(false)
  111. -- Iteration 8 --
  112. Copy operation => bool(true)
  113. Existence of destination file => bool(true)
  114. Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp
  115. Size of source file => int(0)
  116. Size of destination file => int(0)
  117. *** Done ***