copy_variation17.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --TEST--
  2. Test copy() function: usage variations - wildcard chars in source
  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 the source file which is given with the combination of wild-card chars */
  10. $file_path = dirname(__FILE__);
  11. echo "*** Test copy() function: With source file names containing wild-card chars ***\n";
  12. $src_file = $file_path."/copy_variation17.tmp";
  13. $file_handle = fopen($src_file, "w");
  14. fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
  15. fclose($file_handle);
  16. $dir = $file_path."/copy_variation17";
  17. mkdir($dir);
  18. $src_file_names = array(
  19. $file_path."/copy_variation17.tmp", //without wild-card char
  20. $file_path."/copy*17.tmp",
  21. $file_path."/*_variation17.tmp",
  22. $file_path."/copy_variation*.tmp",
  23. $file_path."/*.tmp"
  24. );
  25. $dest_file_name = $dir."/copy_copy_variation17.tmp";
  26. $count = 1;
  27. foreach($src_file_names as $src_file_name) {
  28. var_dump( copy($src_file_name, $dest_file_name) );
  29. var_dump( file_exists($dest_file_name) );
  30. if( file_exists($dest_file_name) ) {
  31. var_dump( filesize($dest_file_name) ); //size of destination
  32. unlink($dest_file_name);
  33. }
  34. $count++;
  35. }
  36. echo "*** Done ***\n";
  37. ?>
  38. --CLEAN--
  39. <?php
  40. unlink(dirname(__FILE__)."/copy_variation17.tmp");
  41. rmdir(dirname(__FILE__)."/copy_variation17");
  42. ?>
  43. --EXPECTF--
  44. *** Test copy() function: With source file names containing wild-card chars ***
  45. bool(true)
  46. bool(true)
  47. int(1500)
  48. Warning: copy(%s): %s
  49. bool(false)
  50. bool(false)
  51. Warning: copy(%s): %s
  52. bool(false)
  53. bool(false)
  54. Warning: copy(%s): %s
  55. bool(false)
  56. bool(false)
  57. Warning: copy(%s): %s
  58. bool(false)
  59. bool(false)
  60. *** Done ***