Annotation of embedaddon/php/ext/standard/tests/file/copy_variation6.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test copy() function: usage variations - copy empty file across dirs
                      3: --SKIPIF--
                      4: <?php
                      5: if(substr(PHP_OS, 0, 3) == "WIN")
                      6:   die("skip Do not run 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 "*** Test copy() function: copying file across directories ***\n";
                     19: $base_dir = dirname(__FILE__)."/copy_variation6";
                     20: mkdir($base_dir);
                     21: 
                     22: $sub_dir = $base_dir."/copy_variation6_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_variation6.tmp";
                     29: fclose( fopen($src_file_name, "w") );
                     30: 
                     31: echo "Size of source file => ";
                     32: var_dump( filesize($src_file_name) );
                     33: clearstatcache();
                     34: 
                     35: $dests = array(
                     36:   $base_dir."/copy_copy_variation6.tmp",
                     37:   $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp",
                     38:   "$sub_dir/copy_copy_variation6.tmp",
                     39:   "$sub_dir/../copy_copy_variation6.tmp",
                     40:   "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp",
                     41:   "$sub_dir/..///../copy_copy_variation6.tmp",
                     42:   "$sub_dir/..///../*",
                     43:   "$dirname_with_blank/copy_copy_variation6.tmp"
                     44: );
                     45: 
                     46: echo "\n-- Now applying copy() on source file to create copies --";
                     47: $count = 1;
                     48: foreach($dests as $dest) {
                     49:   echo "\n-- Iteration $count --\n";
                     50: 
                     51:   echo "Copy operation => ";
                     52:   var_dump( copy($src_file_name, $dest) );
                     53: 
                     54:   echo "Existence of destination file => ";
                     55:   var_dump( file_exists($dest) );
                     56: 
                     57:   echo "Destination file name is => ";
                     58:   print($dest);
                     59:   echo "\n";
                     60: 
                     61:   echo "Size of source file => ";
                     62:   var_dump( filesize($src_file_name) );
                     63:   clearstatcache();
                     64: 
                     65:   echo "Size of destination file => ";
                     66:   var_dump( filesize($dest) );
                     67:   clearstatcache();
                     68: 
                     69:   unlink("$dest");
                     70: 
                     71:   $count++;
                     72: }
                     73: 
                     74: unlink($src_file_name);
                     75: rmdir($dirname_with_blank);
                     76: rmdir($sub_dir);
                     77: rmdir($base_dir);
                     78: 
                     79: echo "*** Done ***\n";
                     80: ?>
                     81: 
                     82: --EXPECTF--
                     83: *** Test copy() function: copying file across directories ***
                     84: Size of source file => int(0)
                     85: 
                     86: -- Now applying copy() on source file to create copies --
                     87: -- Iteration 1 --
                     88: Copy operation => bool(true)
                     89: Existence of destination file => bool(true)
                     90: Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp
                     91: Size of source file => int(0)
                     92: Size of destination file => int(0)
                     93: 
                     94: -- Iteration 2 --
                     95: Copy operation => bool(true)
                     96: Existence of destination file => bool(true)
                     97: Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
                     98: Size of source file => int(0)
                     99: Size of destination file => int(0)
                    100: 
                    101: -- Iteration 3 --
                    102: Copy operation => bool(true)
                    103: Existence of destination file => bool(true)
                    104: Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
                    105: Size of source file => int(0)
                    106: Size of destination file => int(0)
                    107: 
                    108: -- Iteration 4 --
                    109: Copy operation => bool(true)
                    110: Existence of destination file => bool(true)
                    111: Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp
                    112: Size of source file => int(0)
                    113: Size of destination file => int(0)
                    114: 
                    115: -- Iteration 5 --
                    116: Copy operation => bool(true)
                    117: Existence of destination file => bool(true)
                    118: Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp
                    119: Size of source file => int(0)
                    120: Size of destination file => int(0)
                    121: 
                    122: -- Iteration 6 --
                    123: Copy operation => bool(true)
                    124: Existence of destination file => bool(true)
                    125: Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp
                    126: Size of source file => int(0)
                    127: Size of destination file => int(0)
                    128: 
                    129: -- Iteration 7 --
                    130: Copy operation => bool(true)
                    131: Existence of destination file => bool(true)
                    132: Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../*
                    133: Size of source file => int(0)
                    134: Size of destination file => int(0)
                    135: 
                    136: -- Iteration 8 --
                    137: Copy operation => bool(true)
                    138: Existence of destination file => bool(true)
                    139: Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp
                    140: Size of source file => int(0)
                    141: Size of destination file => int(0)
                    142: *** Done ***

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