copy_variation16-win32.phpt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. /* Test copy() function: Trying to create copy of source file
  11. into different destination dir paths given in various notations */
  12. echo "*** Testing copy() function: copying data file across directories ***\n";
  13. $base_dir = __DIR__."/copy_variation16";
  14. mkdir($base_dir);
  15. $sub_dir = $base_dir."/copy_variation16_sub";
  16. mkdir($sub_dir);
  17. $dirname_with_blank = $sub_dir."/copy variation16";
  18. mkdir($dirname_with_blank);
  19. $src_file_name = __DIR__."/copy_variation16.tmp";
  20. $file_handle = fopen($src_file_name, "w");
  21. fwrite($file_handle, str_repeat("Hello world, this is 2007 year ...\n", 100));
  22. fclose($file_handle);
  23. echo "- Size of source file => ";
  24. var_dump( filesize($src_file_name) );
  25. clearstatcache();
  26. $dests = array(
  27. $base_dir."/copy_copy_variation16.tmp",
  28. $base_dir."/copy_variation16_sub/copy_copy_variation16.tmp",
  29. "$sub_dir/copy_copy_variation16.tmp",
  30. "$sub_dir/../copy_copy_variation16.tmp",
  31. "$sub_dir/../copy_variation16_sub/copy_copy_variation16.tmp",
  32. "$sub_dir/..///../copy_copy_variation16.tmp",
  33. "$sub_dir///../*",
  34. "$dirname_with_blank/copy_copy_variation16.tmp"
  35. );
  36. echo "\n--- Now applying copy() on source file to create copies ---";
  37. $count = 1;
  38. foreach($dests as $dest) {
  39. echo "\n-- Iteration $count --\n";
  40. echo "Size of source file => ";
  41. var_dump( filesize($src_file_name) );
  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 destination file => ";
  51. var_dump( filesize($dest) );
  52. clearstatcache();
  53. unlink("$dest");
  54. }
  55. $count++;
  56. }
  57. unlink($src_file_name);
  58. rmdir($dirname_with_blank);
  59. rmdir($sub_dir);
  60. rmdir($base_dir);
  61. echo "*** Done ***\n";
  62. ?>
  63. --EXPECTF--
  64. *** Testing copy() function: copying data file across directories ***
  65. - Size of source file => int(3500)
  66. --- Now applying copy() on source file to create copies ---
  67. -- Iteration 1 --
  68. Size of source file => int(3500)
  69. Copy operation => bool(true)
  70. Existence of destination file => bool(true)
  71. Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp
  72. Size of destination file => int(3500)
  73. -- Iteration 2 --
  74. Size of source file => int(3500)
  75. Copy operation => bool(true)
  76. Existence of destination file => bool(true)
  77. Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
  78. Size of destination file => int(3500)
  79. -- Iteration 3 --
  80. Size of source file => int(3500)
  81. Copy operation => bool(true)
  82. Existence of destination file => bool(true)
  83. Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
  84. Size of destination file => int(3500)
  85. -- Iteration 4 --
  86. Size of source file => int(3500)
  87. Copy operation => bool(true)
  88. Existence of destination file => bool(true)
  89. Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp
  90. Size of destination file => int(3500)
  91. -- Iteration 5 --
  92. Size of source file => int(3500)
  93. Copy operation => bool(true)
  94. Existence of destination file => bool(true)
  95. Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp
  96. Size of destination file => int(3500)
  97. -- Iteration 6 --
  98. Size of source file => int(3500)
  99. Copy operation => bool(true)
  100. Existence of destination file => bool(true)
  101. Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp
  102. Size of destination file => int(3500)
  103. -- Iteration 7 --
  104. Size of source file => int(3500)
  105. Copy operation =>
  106. Warning: copy(%s): Failed to open stream: No such file or directory in %s on line %d
  107. bool(false)
  108. Existence of destination file => bool(false)
  109. -- Iteration 8 --
  110. Size of source file => int(3500)
  111. Copy operation => bool(true)
  112. Existence of destination file => bool(true)
  113. Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation16/copy_copy_variation16.tmp
  114. Size of destination file => int(3500)
  115. *** Done ***