copy_variation16-win32.phpt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. --TEST--
  2. Test copy() function: usage variations - copy data file across dirs
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) != "WIN")
  6. die("skip Run only 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 "*** Testing copy() function: copying data file across directories ***\n";
  17. $base_dir = dirname(__FILE__)."/copy_variation16";
  18. mkdir($base_dir);
  19. $sub_dir = $base_dir."/copy_variation16_sub";
  20. mkdir($sub_dir);
  21. $dirname_with_blank = $sub_dir."/copy variation16";
  22. mkdir($dirname_with_blank);
  23. $src_file_name = dirname(__FILE__)."/copy_variation16.tmp";
  24. $file_handle = fopen($src_file_name, "w");
  25. fwrite($file_handle, str_repeat(b"Hello world, this is 2007 year ...\n", 100));
  26. fclose($file_handle);
  27. echo "- Size of source file => ";
  28. var_dump( filesize($src_file_name) );
  29. clearstatcache();
  30. $dests = array(
  31. $base_dir."/copy_copy_variation16.tmp",
  32. $base_dir."/copy_variation16_sub/copy_copy_variation16.tmp",
  33. "$sub_dir/copy_copy_variation16.tmp",
  34. "$sub_dir/../copy_copy_variation16.tmp",
  35. "$sub_dir/../copy_variation16_sub/copy_copy_variation16.tmp",
  36. "$sub_dir/..///../copy_copy_variation16.tmp",
  37. "$sub_dir/..///../*",
  38. "$dirname_with_blank/copy_copy_variation16.tmp"
  39. );
  40. echo "\n--- Now applying copy() on source file to create copies ---";
  41. $count = 1;
  42. foreach($dests as $dest) {
  43. echo "\n-- Iteration $count --\n";
  44. echo "Size of source file => ";
  45. var_dump( filesize($src_file_name) );
  46. echo "Copy operation => ";
  47. var_dump( copy($src_file_name, $dest) );
  48. echo "Existence of destination file => ";
  49. var_dump( file_exists($dest) );
  50. if( file_exists($dest) ){
  51. echo "Destination file name is => ";
  52. print($dest);
  53. echo "\n";
  54. echo "Size of destination file => ";
  55. var_dump( filesize($dest) );
  56. clearstatcache();
  57. unlink("$dest");
  58. }
  59. $count++;
  60. }
  61. unlink($src_file_name);
  62. rmdir($dirname_with_blank);
  63. rmdir($sub_dir);
  64. rmdir($base_dir);
  65. echo "*** Done ***\n";
  66. ?>
  67. --EXPECTF--
  68. *** Testing copy() function: copying data file across directories ***
  69. - Size of source file => int(3500)
  70. --- Now applying copy() on source file to create copies ---
  71. -- Iteration 1 --
  72. Size of source file => int(3500)
  73. Copy operation => bool(true)
  74. Existence of destination file => bool(true)
  75. Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp
  76. Size of destination file => int(3500)
  77. -- Iteration 2 --
  78. Size of source file => int(3500)
  79. Copy operation => bool(true)
  80. Existence of destination file => bool(true)
  81. Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
  82. Size of destination file => int(3500)
  83. -- Iteration 3 --
  84. Size of source file => int(3500)
  85. Copy operation => bool(true)
  86. Existence of destination file => bool(true)
  87. Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
  88. Size of destination file => int(3500)
  89. -- Iteration 4 --
  90. Size of source file => int(3500)
  91. Copy operation => bool(true)
  92. Existence of destination file => bool(true)
  93. Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp
  94. Size of destination file => int(3500)
  95. -- Iteration 5 --
  96. Size of source file => int(3500)
  97. Copy operation => bool(true)
  98. Existence of destination file => bool(true)
  99. Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp
  100. Size of destination file => int(3500)
  101. -- Iteration 6 --
  102. Size of source file => int(3500)
  103. Copy operation => bool(true)
  104. Existence of destination file => bool(true)
  105. Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp
  106. Size of destination file => int(3500)
  107. -- Iteration 7 --
  108. Size of source file => int(3500)
  109. Copy operation =>
  110. Warning: copy(%s): failed to open stream: No such file or directory in %s on line %s
  111. bool(false)
  112. Existence of destination file => bool(false)
  113. -- Iteration 8 --
  114. Size of source file => int(3500)
  115. Copy operation => bool(true)
  116. Existence of destination file => bool(true)
  117. Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation16/copy_copy_variation16.tmp
  118. Size of destination file => int(3500)
  119. *** Done ***