Annotation of embedaddon/php/ext/standard/tests/file/copy_variation16-win32.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test copy() function: usage variations - copy data file across dirs
                      3: --SKIPIF--
                      4: <?php
                      5: if(substr(PHP_OS, 0, 3) != "WIN")
                      6:   die("skip Run only on Windows");
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: /* Prototype: bool copy ( string $source, string $dest );
                     11:    Description: Makes a copy of the file source to dest.
                     12:      Returns TRUE on success or FALSE on failure.
                     13: */
                     14: 
                     15: /* Test copy() function: Trying to create copy of source file 
                     16:      into different destination dir paths given in various notations */
                     17: 
                     18: echo "*** Testing copy() function: copying data file across directories ***\n";
                     19: $base_dir = dirname(__FILE__)."/copy_variation16";
                     20: mkdir($base_dir);
                     21: 
                     22: $sub_dir = $base_dir."/copy_variation16_sub";
                     23: mkdir($sub_dir);
                     24: 
                     25: $dirname_with_blank = $sub_dir."/copy variation6";
                     26: mkdir($dirname_with_blank);
                     27: 
                     28: $src_file_name = dirname(__FILE__)."/copy_variation16.tmp";
                     29: $file_handle = fopen($src_file_name, "w");
                     30: fwrite($file_handle, str_repeat(b"Hello world, this is 2007 year ...\n", 100));
                     31: fclose($file_handle);
                     32: 
                     33: echo "- Size of source file => ";
                     34: var_dump( filesize($src_file_name) );
                     35: clearstatcache();
                     36: 
                     37: $dests = array(
                     38:   $base_dir."/copy_copy_variation16.tmp",
                     39:   $base_dir."/copy_variation16_sub/copy_copy_variation16.tmp",
                     40:   "$sub_dir/copy_copy_variation16.tmp",
                     41:   "$sub_dir/../copy_copy_variation16.tmp",
                     42:   "$sub_dir/../copy_variation16_sub/copy_copy_variation16.tmp",
                     43:   "$sub_dir/..///../copy_copy_variation16.tmp",
                     44:   "$sub_dir/..///../*",
                     45:   "$dirname_with_blank/copy_copy_variation16.tmp"
                     46: );
                     47: 
                     48: echo "\n--- Now applying copy() on source file to create copies ---";
                     49: $count = 1;
                     50: foreach($dests as $dest) {
                     51:   echo "\n-- Iteration $count --\n";
                     52: 
                     53:   echo "Size of source file => ";
                     54:   var_dump( filesize($src_file_name) );
                     55: 
                     56:   echo "Copy operation => ";
                     57:   var_dump( copy($src_file_name, $dest) );
                     58: 
                     59:   echo "Existence of destination file => ";
                     60:   var_dump( file_exists($dest) );
                     61: 
                     62:   if( file_exists($dest) ){
                     63:     echo "Destination file name is => ";
                     64:     print($dest);
                     65:     echo "\n";
                     66: 
                     67:     echo "Size of destination file => ";
                     68:     var_dump( filesize($dest) );
                     69:     clearstatcache();
                     70: 
                     71:     unlink("$dest");
                     72:   }
                     73:   $count++;
                     74: }
                     75: 
                     76: unlink($src_file_name);
                     77: rmdir($dirname_with_blank);
                     78: rmdir($sub_dir);
                     79: rmdir($base_dir);
                     80: 
                     81: echo "*** Done ***\n";
                     82: ?>
                     83: 
                     84: --EXPECTF--
                     85: *** Testing copy() function: copying data file across directories ***
                     86: - Size of source file => int(3500)
                     87: 
                     88: --- Now applying copy() on source file to create copies ---
                     89: -- Iteration 1 --
                     90: Size of source file => int(3500)
                     91: Copy operation => bool(true)
                     92: Existence of destination file => bool(true)
                     93: Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp
                     94: Size of destination file => int(3500)
                     95: 
                     96: -- Iteration 2 --
                     97: Size of source file => int(3500)
                     98: Copy operation => bool(true)
                     99: Existence of destination file => bool(true)
                    100: Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
                    101: Size of destination file => int(3500)
                    102: 
                    103: -- Iteration 3 --
                    104: Size of source file => int(3500)
                    105: Copy operation => bool(true)
                    106: Existence of destination file => bool(true)
                    107: Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
                    108: Size of destination file => int(3500)
                    109: 
                    110: -- Iteration 4 --
                    111: Size of source file => int(3500)
                    112: Copy operation => bool(true)
                    113: Existence of destination file => bool(true)
                    114: Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp
                    115: Size of destination file => int(3500)
                    116: 
                    117: -- Iteration 5 --
                    118: Size of source file => int(3500)
                    119: Copy operation => bool(true)
                    120: Existence of destination file => bool(true)
                    121: Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp
                    122: Size of destination file => int(3500)
                    123: 
                    124: -- Iteration 6 --
                    125: Size of source file => int(3500)
                    126: Copy operation => bool(true)
                    127: Existence of destination file => bool(true)
                    128: Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp
                    129: Size of destination file => int(3500)
                    130: 
                    131: -- Iteration 7 --
                    132: Size of source file => int(3500)
                    133: Copy operation => 
                    134: Warning: copy(%s): failed to open stream: No such file or directory in %s on line %s
                    135: bool(false)
                    136: Existence of destination file => bool(false)
                    137: 
                    138: -- Iteration 8 --
                    139: Size of source file => int(3500)
                    140: Copy operation => bool(true)
                    141: Existence of destination file => bool(true)
                    142: Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp
                    143: Size of destination file => int(3500)
                    144: *** Done ***

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>