copy_variation18.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Test copy() function: usage variations - stat after copy
  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(): checking stat of file before and after after copy operation */
  10. $file_path = dirname(__FILE__);
  11. require($file_path."/file.inc");
  12. echo "*** Test copy() function: stat of file before and after copy ***\n";
  13. $src_file_name = $file_path."/copy_variation18.tmp";
  14. $file_handle = fopen($src_file_name, "w");
  15. fwrite($file_handle, str_repeat("Hello2world...\n", 100));
  16. fclose($file_handle);
  17. $dest_file_name = $file_path."/copy_copy_variation18.tmp";
  18. clearstatcache();
  19. $stat_before_copy = stat($src_file_name);
  20. clearstatcache();
  21. echo "Copy operation => ";
  22. var_dump( copy($src_file_name, $dest_file_name) );
  23. $stat_after_copy = stat($src_file_name);
  24. clearstatcache();
  25. // compare all stat fields except access time
  26. $stat_keys_to_compare = array("dev", "ino", "mode", "nlink", "uid", "gid",
  27. "rdev", "size", "mtime", "ctime",
  28. "blksize", "blocks");
  29. echo "Comparing the stats of file before and after copy operation => ";
  30. var_dump( compare_stats($stat_before_copy, $stat_after_copy, $stat_keys_to_compare) );
  31. echo "*** Done ***\n";
  32. ?>
  33. --CLEAN--
  34. <?php
  35. unlink(dirname(__FILE__)."/copy_copy_variation18.tmp");
  36. unlink(dirname(__FILE__)."/copy_variation18.tmp");
  37. ?>
  38. --EXPECTF--
  39. *** Test copy() function: stat of file before and after copy ***
  40. Copy operation => bool(true)
  41. Comparing the stats of file before and after copy operation => bool(true)
  42. *** Done ***