Annotation of embedaddon/php/ext/standard/tests/file/copy_variation16.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 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 "*** 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("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:   echo "Destination file name is => ";
                     63:   print($dest);
                     64:   echo "\n";
                     65: 
                     66:   echo "Size of destination file => ";
                     67:   var_dump( filesize($dest) );
                     68:   clearstatcache();
                     69: 
                     70:   unlink("$dest");
                     71: 
                     72:   $count++;
                     73: }
                     74: 
                     75: unlink($src_file_name);
                     76: rmdir($dirname_with_blank);
                     77: rmdir($sub_dir);
                     78: rmdir($base_dir);
                     79: 
                     80: echo "*** Done ***\n";
                     81: ?>
                     82: 
                     83: --EXPECTF--
                     84: *** Testing copy() function: copying data file across directories ***
                     85: - Size of source file => int(3500)
                     86: 
                     87: --- Now applying copy() on source file to create copies ---
                     88: -- Iteration 1 --
                     89: Size of source file => int(3500)
                     90: Copy operation => bool(true)
                     91: Existence of destination file => bool(true)
                     92: Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp
                     93: Size of destination file => int(3500)
                     94: 
                     95: -- Iteration 2 --
                     96: Size of source file => int(3500)
                     97: Copy operation => bool(true)
                     98: Existence of destination file => bool(true)
                     99: Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
                    100: Size of destination file => int(3500)
                    101: 
                    102: -- Iteration 3 --
                    103: Size of source file => int(3500)
                    104: Copy operation => bool(true)
                    105: Existence of destination file => bool(true)
                    106: Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
                    107: Size of destination file => int(3500)
                    108: 
                    109: -- Iteration 4 --
                    110: Size of source file => int(3500)
                    111: Copy operation => bool(true)
                    112: Existence of destination file => bool(true)
                    113: Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp
                    114: Size of destination file => int(3500)
                    115: 
                    116: -- Iteration 5 --
                    117: Size of source file => int(3500)
                    118: Copy operation => bool(true)
                    119: Existence of destination file => bool(true)
                    120: Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp
                    121: Size of destination file => int(3500)
                    122: 
                    123: -- Iteration 6 --
                    124: Size of source file => int(3500)
                    125: Copy operation => bool(true)
                    126: Existence of destination file => bool(true)
                    127: Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp
                    128: Size of destination file => int(3500)
                    129: 
                    130: -- Iteration 7 --
                    131: Size of source file => int(3500)
                    132: Copy operation => bool(true)
                    133: Existence of destination file => bool(true)
                    134: Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../*
                    135: Size of destination file => int(3500)
                    136: 
                    137: -- Iteration 8 --
                    138: Size of source file => int(3500)
                    139: Copy operation => bool(true)
                    140: Existence of destination file => bool(true)
                    141: Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp
                    142: Size of destination file => int(3500)
                    143: *** Done ***

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