copy_basic.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Test copy() function: basic functionality
  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. echo "*** Testing copy() function: to copy file from source to destination --\n";
  10. var_dump( file_exists(__FILE__) );
  11. /* copying the file */
  12. $file_path = dirname(__FILE__);
  13. $file_name1 = $file_path."/copy_basic1.tmp";
  14. $file_name2 = $file_path."/copy_basic2.tmp";
  15. var_dump( copy(__FILE__, $file_name1) );
  16. var_dump( copy($file_name1, $file_name2) );
  17. echo "-- Checking whether the copy of file exists --\n";
  18. var_dump( file_exists($file_name1) );
  19. var_dump( file_exists($file_name2) );
  20. echo "-- Checking filepermissions of file and its copies --\n";
  21. printf( "%o", fileperms(__FILE__) );
  22. echo "\n";
  23. printf( "%o", fileperms($file_name1) );
  24. echo "\n";
  25. printf( "%o", fileperms($file_name2) );
  26. echo "\n";
  27. echo "*** Done ***\n";
  28. ?>
  29. --CLEAN--
  30. <?php
  31. $file_path = dirname(__FILE__);
  32. $file_name1 = $file_path."/copy_basic1.tmp";
  33. $file_name2 = $file_path."/copy_basic2.tmp";
  34. unlink($file_name1);
  35. unlink($file_name2);
  36. ?>
  37. --EXPECTF--
  38. *** Testing copy() function: to copy file from source to destination --
  39. bool(true)
  40. bool(true)
  41. bool(true)
  42. -- Checking whether the copy of file exists --
  43. bool(true)
  44. bool(true)
  45. -- Checking filepermissions of file and its copies --
  46. %d
  47. %d
  48. %d
  49. *** Done ***