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