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

1.1       misho       1: --TEST--
                      2: chmod() with various paths
                      3: --SKIPIF--
                      4: <?php
                      5: if (substr(PHP_OS, 0, 3) == 'WIN') {
                      6:     die('skip non-windows only test');
                      7: }
                      8: ?>
                      9: --FILE--
                     10: <?php
                     11: 
                     12: define("PERMISSIONS_MASK", 0777);
                     13: 
                     14: $script_directory = dirname(__FILE__);
                     15: chdir($script_directory);
                     16: $test_dirname = basename(__FILE__, ".php") . "testdir";
                     17: mkdir($test_dirname);
                     18: 
                     19: $filepath = __FILE__ . ".tmp";
                     20: $filename = basename($filepath);
                     21: $fd = fopen($filepath, "w+");
                     22: fclose($fd);
                     23: 
                     24: echo "chmod() on a path containing .. and .\n";
                     25: var_dump(chmod("./$test_dirname/../$filename", 0777));
                     26: var_dump(chmod("./$test_dirname/../$filename", 0755));
                     27: clearstatcache();
                     28: printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
                     29: 
                     30: echo "\nchmod() on a path containing .. with invalid directories\n";
                     31: var_dump(chmod($filepath, 0777));
                     32: var_dump(chmod("./$test_dirname/bad_dir/../../$filename", 0755));
                     33: clearstatcache();
                     34: printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
                     35:  
                     36: echo "\nchmod() on a linked file\n";
                     37: $linkname = "somelink";
                     38: var_dump(symlink($filepath, $linkname));
                     39: var_dump(chmod($filepath, 0777));
                     40: var_dump(chmod($linkname, 0755));
                     41: clearstatcache();
                     42: printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
                     43: var_dump(unlink($linkname));
                     44: 
                     45: echo "\nchmod() on a relative path from a different working directory\n";
                     46: chdir($test_dirname);
                     47: var_dump(chmod("../$filename", 0777));
                     48: var_dump(chmod("../$filename", 0755));
                     49: clearstatcache();
                     50: printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
                     51: chdir($script_directory);
                     52: 
                     53: echo "\nchmod() on a directory with a trailing /\n";
                     54: var_dump(chmod($test_dirname, 0777));
                     55: var_dump(chmod("$test_dirname/", 0775));
                     56: clearstatcache();
                     57: printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
                     58: 
                     59: chdir($script_directory);
                     60: rmdir($test_dirname);
                     61: unlink($filepath);
                     62: 
                     63: ?>
                     64: --EXPECTF--
                     65: chmod() on a path containing .. and .
                     66: bool(true)
                     67: bool(true)
                     68: 755
                     69: 
                     70: chmod() on a path containing .. with invalid directories
                     71: bool(true)
                     72: 
                     73: Warning: chmod(): No such file or directory in %s on line %d
                     74: bool(false)
                     75: 777
                     76: 
                     77: chmod() on a linked file
                     78: bool(true)
                     79: bool(true)
                     80: bool(true)
                     81: 755
                     82: bool(true)
                     83: 
                     84: chmod() on a relative path from a different working directory
                     85: bool(true)
                     86: bool(true)
                     87: 755
                     88: 
                     89: chmod() on a directory with a trailing /
                     90: bool(true)
                     91: bool(true)
                     92: 755

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