copy_variation17.phpt 1.5 KB

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