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

1.1       misho       1: --TEST--
                      2: Test copy() function: usage variations - copying links across dirs
                      3: --SKIPIF--
                      4: <?php
                      5: if(substr(PHP_OS, 0, 3) == "WIN")
                      6:   die("skip Invalid for 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: /* Trying to copy the links across dir paths given in various notations 
                     16:      and dirs having limited access */
                     17: 
                     18: echo "*** Testing copy() function: copying links across different directories ***\n";
                     19: 
                     20: $file_path = dirname(__FILE__);
                     21: 
                     22: $base_dir = $file_path."/copy_variation8";
                     23: mkdir($base_dir);
                     24: $sub_dir = $base_dir."/copy_variation8_sub";
                     25: mkdir($sub_dir);
                     26: $dirname_with_blank = $sub_dir."/copy variation6";
                     27: mkdir($dirname_with_blank);
                     28: 
                     29: $file = $file_path."/copy_variation8.tmp";
                     30: fclose( fopen($file, "w") );
                     31: 
                     32: $symlink = $file_path."/copy_variation8_symlink.tmp";
                     33: $hardlink = $file_path."/copy_variation8_hardlink.tmp";
                     34: 
                     35: symlink($file, $symlink);  //creating symlink
                     36: link($file, $hardlink);  //creating hardlink
                     37: 
                     38: $dests = array(
                     39:   $base_dir."/copy_copy_variation8.tmp",
                     40:   $base_dir."/copy_variation8_sub/copy_copy_variation8.tmp",
                     41:   "$sub_dir/copy_copy_variation8.tmp",
                     42:   "$sub_dir/../copy_copy_variation8.tmp",
                     43:   "$sub_dir/../copy_variation8_sub/copy_copy_variation8.tmp",
                     44:   "$sub_dir/..///../copy_copy_variation8.tmp",
                     45:   "$sub_dir/..///../*",
                     46:   "$dirname_with_blank/copy_copy_variation8.tmp"
                     47: );
                     48: 
                     49: $count = 1;
                     50: foreach($dests as $dest) {
                     51:   echo "\n-- Iteration $count --\n";
                     52:   echo "- With symlink -\n";
                     53:   var_dump( copy($symlink, $dest) );
                     54:   var_dump( file_exists($dest) );
                     55:   var_dump( is_link($dest) ); //expected: bool(false)
                     56:   var_dump( is_file($dest) );  //expected: bool(true)
                     57:   clearstatcache();
                     58:   unlink("$dest");
                     59:   echo "- With hardlink -\n";
                     60:   var_dump( copy($hardlink, $dest) );
                     61:   var_dump( file_exists($dest) );
                     62:   var_dump( is_link($dest) );  //expected: bool(flase)
                     63:   var_dump( is_file($dest) );  //expected: bool(true)
                     64:   clearstatcache();
                     65:   unlink("$dest");
                     66:   $count++;
                     67: }
                     68: 
                     69: unlink($symlink);
                     70: unlink($hardlink);
                     71: unlink($file);
                     72: rmdir($dirname_with_blank);
                     73: rmdir($sub_dir);
                     74: rmdir($base_dir);
                     75: 
                     76: echo "*** Done ***\n";
                     77: ?>
                     78: --EXPECTF--
                     79: *** Testing copy() function: copying links across different directories ***
                     80: 
                     81: -- Iteration 1 --
                     82: - With symlink -
                     83: bool(true)
                     84: bool(true)
                     85: bool(false)
                     86: bool(true)
                     87: - With hardlink -
                     88: bool(true)
                     89: bool(true)
                     90: bool(false)
                     91: bool(true)
                     92: 
                     93: -- Iteration 2 --
                     94: - With symlink -
                     95: bool(true)
                     96: bool(true)
                     97: bool(false)
                     98: bool(true)
                     99: - With hardlink -
                    100: bool(true)
                    101: bool(true)
                    102: bool(false)
                    103: bool(true)
                    104: 
                    105: -- Iteration 3 --
                    106: - With symlink -
                    107: bool(true)
                    108: bool(true)
                    109: bool(false)
                    110: bool(true)
                    111: - With hardlink -
                    112: bool(true)
                    113: bool(true)
                    114: bool(false)
                    115: bool(true)
                    116: 
                    117: -- Iteration 4 --
                    118: - With symlink -
                    119: bool(true)
                    120: bool(true)
                    121: bool(false)
                    122: bool(true)
                    123: - With hardlink -
                    124: bool(true)
                    125: bool(true)
                    126: bool(false)
                    127: bool(true)
                    128: 
                    129: -- Iteration 5 --
                    130: - With symlink -
                    131: bool(true)
                    132: bool(true)
                    133: bool(false)
                    134: bool(true)
                    135: - With hardlink -
                    136: bool(true)
                    137: bool(true)
                    138: bool(false)
                    139: bool(true)
                    140: 
                    141: -- Iteration 6 --
                    142: - With symlink -
                    143: bool(true)
                    144: bool(true)
                    145: bool(false)
                    146: bool(true)
                    147: - With hardlink -
                    148: bool(true)
                    149: bool(true)
                    150: bool(false)
                    151: bool(true)
                    152: 
                    153: -- Iteration 7 --
                    154: - With symlink -
                    155: bool(true)
                    156: bool(true)
                    157: bool(false)
                    158: bool(true)
                    159: - With hardlink -
                    160: bool(true)
                    161: bool(true)
                    162: bool(false)
                    163: bool(true)
                    164: 
                    165: -- Iteration 8 --
                    166: - With symlink -
                    167: bool(true)
                    168: bool(true)
                    169: bool(false)
                    170: bool(true)
                    171: - With hardlink -
                    172: bool(true)
                    173: bool(true)
                    174: bool(false)
                    175: bool(true)
                    176: *** Done ***

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