123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- --TEST--
- Test copy() function: usage variations - copying links across dirs
- --SKIPIF--
- <?php
- if(substr(PHP_OS, 0, 3) == "WIN")
- die("skip Invalid for Windows");
- ?>
- --FILE--
- <?php
- /* Trying to copy the links across dir paths given in various notations
- and dirs having limited access */
- echo "*** Testing copy() function: copying links across different directories ***\n";
- $file_path = __DIR__;
- $base_dir = $file_path."/copy_variation8";
- mkdir($base_dir);
- $sub_dir = $base_dir."/copy_variation8_sub";
- mkdir($sub_dir);
- $dirname_with_blank = $sub_dir."/copy variation6";
- mkdir($dirname_with_blank);
- $file = $file_path."/copy_variation8.tmp";
- fclose( fopen($file, "w") );
- $symlink = $file_path."/copy_variation8_symlink.tmp";
- $hardlink = $file_path."/copy_variation8_hardlink.tmp";
- symlink($file, $symlink); //creating symlink
- link($file, $hardlink); //creating hardlink
- $dests = array(
- $base_dir."/copy_copy_variation8.tmp",
- $base_dir."/copy_variation8_sub/copy_copy_variation8.tmp",
- "$sub_dir/copy_copy_variation8.tmp",
- "$sub_dir/../copy_copy_variation8.tmp",
- "$sub_dir/../copy_variation8_sub/copy_copy_variation8.tmp",
- "$sub_dir/..///../copy_copy_variation8.tmp",
- "$sub_dir///../*",
- "$dirname_with_blank/copy_copy_variation8.tmp"
- );
- $count = 1;
- foreach($dests as $dest) {
- echo "\n-- Iteration $count --\n";
- echo "- With symlink -\n";
- var_dump( copy($symlink, $dest) );
- var_dump( file_exists($dest) );
- var_dump( is_link($dest) ); //expected: bool(false)
- var_dump( is_file($dest) ); //expected: bool(true)
- clearstatcache();
- unlink("$dest");
- echo "- With hardlink -\n";
- var_dump( copy($hardlink, $dest) );
- var_dump( file_exists($dest) );
- var_dump( is_link($dest) ); //expected: bool(flase)
- var_dump( is_file($dest) ); //expected: bool(true)
- clearstatcache();
- unlink("$dest");
- $count++;
- }
- unlink($symlink);
- unlink($hardlink);
- unlink($file);
- rmdir($dirname_with_blank);
- rmdir($sub_dir);
- rmdir($base_dir);
- echo "*** Done ***\n";
- ?>
- --EXPECT--
- *** Testing copy() function: copying links across different directories ***
- -- Iteration 1 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- -- Iteration 2 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- -- Iteration 3 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- -- Iteration 4 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- -- Iteration 5 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- -- Iteration 6 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- -- Iteration 7 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- -- Iteration 8 --
- - With symlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- - With hardlink -
- bool(true)
- bool(true)
- bool(false)
- bool(true)
- *** Done ***
|