copy_variation14.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Test copy() function: usage variations - non existing src/dest
  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 create a copy of non-existing source in an existing destination
  10. and an existing source in non-existing destiantion */
  11. $file_path = dirname(__FILE__);
  12. echo "*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***";
  13. $file = $file_path."/copy_variation14.tmp";
  14. $file_handle = fopen($file, "w");
  15. fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
  16. fclose($file_handle);
  17. var_dump( copy($file_path."/nosuchfile.tmp", $file_path."/copy_nosuchfile.tmp") ); //With non-existing source
  18. var_dump( file_exists($file_path."/copy_nosuchfile.tmp") );
  19. echo "\n*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***";
  20. var_dump( copy($file, $file_path."/nodir/copy_nosuchfile.tmp") ); //With non-existing dir path
  21. var_dump( file_exists($file_path."/nodir/copy_nosuchfile.tmp") );
  22. var_dump( filesize($file) ); //size of the source
  23. echo "*** Done ***\n";
  24. ?>
  25. --CLEAN--
  26. <?php
  27. unlink(dirname(__FILE__)."/copy_variation14.tmp");
  28. ?>
  29. --EXPECTF--
  30. *** Test copy() function: Trying to create a copy of non-existing source in existing destination ***
  31. Warning: copy(%s): %s
  32. bool(false)
  33. bool(false)
  34. *** Test copy() function: Trying to create copy of an existing source in non-existing destination ***
  35. Warning: copy(%s): %s
  36. bool(false)
  37. bool(false)
  38. int(1500)
  39. *** Done ***