copy_variation13.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test copy() function: usage variations - src as dir and dest as an existing file(Bug #42243)
  3. --FILE--
  4. <?php
  5. /* Prototype: bool copy ( string $source, string $dest );
  6. Description: Makes a copy of the file source to dest.
  7. Returns TRUE on success or FALSE on failure.
  8. */
  9. /* Test copy(): Trying to copy dir to an existing file */
  10. echo "*** Test copy() function: Trying to copy dir to file ***\n";
  11. $file_path = dirname(__FILE__);
  12. $file = $file_path."/copy_variation13_dir.tmp";
  13. fclose(fopen($file, "w"));
  14. $dir = $file_path."/copy_variation13";
  15. mkdir($dir);
  16. echo "*** Testing copy() in copying dir to file ***\n";
  17. var_dump( copy($dir, $file) );
  18. var_dump( file_exists($file) );
  19. var_dump( file_exists($dir) );
  20. var_dump( is_file($dir) );
  21. var_dump( is_dir($dir) );
  22. var_dump( is_file($file) );
  23. var_dump( is_dir($file) );
  24. var_dump( filesize($file) );
  25. var_dump( filesize($dir) );
  26. echo "*** Done ***\n";
  27. ?>
  28. --CLEAN--
  29. <?php
  30. unlink(dirname(__FILE__)."/copy_variation13_dir.tmp");
  31. rmdir(dirname(__FILE__)."/copy_variation13");
  32. ?>
  33. --EXPECTF--
  34. *** Test copy() function: Trying to copy dir to file ***
  35. *** Testing copy() in copying dir to file ***
  36. Warning: copy(): The first argument to copy() function cannot be a directory in %scopy_variation13.php on line %d
  37. bool(false)
  38. bool(true)
  39. bool(true)
  40. bool(false)
  41. bool(true)
  42. bool(true)
  43. bool(false)
  44. int(%d)
  45. int(%d)
  46. *** Done ***