copy_variation11.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Test copy() function: usage variations - existing dir as destination
  3. --FILE--
  4. <?php
  5. /* Test copy(): Trying to copy the file to a destination, where destination is an existing dir */
  6. $file_path = __DIR__;
  7. echo "*** Test copy() function: Trying to create a copy of source file as a dir ***\n";
  8. $file = $file_path."/copy_variation11.tmp";
  9. $file_handle = fopen($file, "w");
  10. fwrite($file_handle, str_repeat("Hello, world...", 20));
  11. fclose($file_handle);
  12. $dir = $file_path."/copy_variation11";
  13. mkdir($dir);
  14. echo "Size of source before copy operation => ";
  15. var_dump( filesize($file) ); //size of source before copy
  16. clearstatcache();
  17. echo "Size of destination before copy operation => ";
  18. var_dump( filesize($dir) ); //size of destination before copy
  19. clearstatcache();
  20. echo "\n-- Now applying copy() operation --\n";
  21. var_dump( copy($file, $dir) ); //expected: bool(false)
  22. var_dump( file_exists($file) ); //expected: bool(true)
  23. var_dump( file_exists($dir) ); //expected: bool(true)
  24. var_dump( is_file($file) ); //expected: bool(true)
  25. var_dump( is_dir($file) ); //expected: bool(false)
  26. var_dump( is_file($dir) ); //expected: bool(false)
  27. var_dump( is_dir($dir) ); //expected: bool(true)
  28. var_dump( filesize($file) ); //size of source after copy
  29. var_dump( filesize($dir) ); //size of destination after copy
  30. echo "*** Done ***\n";
  31. ?>
  32. --CLEAN--
  33. <?php
  34. unlink(__DIR__."/copy_variation11.tmp");
  35. rmdir(__DIR__."/copy_variation11");
  36. ?>
  37. --EXPECTF--
  38. *** Test copy() function: Trying to create a copy of source file as a dir ***
  39. Size of source before copy operation => int(300)
  40. Size of destination before copy operation => int(%d)
  41. -- Now applying copy() operation --
  42. Warning: %s
  43. bool(false)
  44. bool(true)
  45. bool(true)
  46. bool(true)
  47. bool(false)
  48. bool(false)
  49. bool(true)
  50. int(300)
  51. int(%d)
  52. *** Done ***