Annotation of embedaddon/php/ext/standard/tests/dir/scandir_variation7.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test scandir() function : usage variations - different directory permissions
                      3: --SKIPIF--
                      4: <?php
                      5: if( substr(PHP_OS, 0, 3) == 'WIN') {
                      6:   die('skip Not for Windows');
                      7: }
                      8: // Skip if being run by root (files are always readable, writeable and executable)
                      9: $filename = dirname(__FILE__) . "/dir_root_check.tmp";
                     10: $fp = fopen($filename, 'w');
                     11: fclose($fp);
                     12: if(fileowner($filename) == 0) {
                     13:         unlink ($filename);
                     14:         die('skip...cannot be run as root\n');
                     15: }
                     16: unlink($filename);
                     17: ?>
                     18: --FILE--
                     19: <?php
                     20: /* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
                     21:  * Description: List files & directories inside the specified path 
                     22:  * Source code: ext/standard/dir.c
                     23:  */
                     24: 
                     25: /*
                     26:  * Create directories with different permissions to test whether scandir() can access them
                     27:  */
                     28: 
                     29: echo "*** Testing scandir() : usage variations ***\n";
                     30: 
                     31: // create the temporary directory
                     32: $dir_path = dirname(__FILE__) . "/scandir_variation7";
                     33: mkdir($dir_path);
                     34: 
                     35: // different values for directory permissions
                     36: $permission_values = array(
                     37: /*1*/  0477,  // owner has read only, other and group has rwx
                     38:        0677,  // owner has rw only, other and group has rwx
                     39: 
                     40: /*3*/  0444,  // all have read only
                     41:        0666,  // all have rw only
                     42: 
                     43: /*5*/  0400,  // owner has read only, group and others have no permission
                     44:        0600,   // owner has rw only, group and others have no permission
                     45: 
                     46: /*7*/  0470,  // owner has read only, group has rwx & others have no permission
                     47:        0407,  // owner has read only, other has rwx & group has no permission
                     48: 
                     49: /*9*/  0670,  // owner has rw only, group has rwx & others have no permission
                     50: /*10*/ 0607   // owner has rw only, group has no permission and others have rwx
                     51: );
                     52: 
                     53: $iterator = 1;
                     54: foreach ($permission_values as $perm) {
                     55:        echo "\n-- Iteration $iterator --\n";
                     56:        
                     57:        // Remove the directory if already exists
                     58:        if (is_dir($dir_path)){
                     59:                chmod ($dir_path, 0777); // change dir permission to allow all operation
                     60:                rmdir ($dir_path);
                     61:        }
                     62:        mkdir($dir_path);
                     63: 
                     64:        // change the dir permisson to test dir on it
                     65:        var_dump( chmod($dir_path, $perm) );
                     66:        
                     67:        var_dump(scandir($dir_path));
                     68:        $iterator++;
                     69: }
                     70: ?>
                     71: ===DONE===
                     72: --CLEAN--
                     73: <?php
                     74: $dir_path = dirname(__FILE__) . "/scandir_variation7";
                     75: rmdir($dir_path);
                     76: ?>
                     77: --EXPECTF--
                     78: *** Testing scandir() : usage variations ***
                     79: 
                     80: -- Iteration 1 --
                     81: bool(true)
                     82: array(2) {
                     83:   [0]=>
                     84:   string(1) "."
                     85:   [1]=>
                     86:   string(2) ".."
                     87: }
                     88: 
                     89: -- Iteration 2 --
                     90: bool(true)
                     91: array(2) {
                     92:   [0]=>
                     93:   string(1) "."
                     94:   [1]=>
                     95:   string(2) ".."
                     96: }
                     97: 
                     98: -- Iteration 3 --
                     99: bool(true)
                    100: array(2) {
                    101:   [0]=>
                    102:   string(1) "."
                    103:   [1]=>
                    104:   string(2) ".."
                    105: }
                    106: 
                    107: -- Iteration 4 --
                    108: bool(true)
                    109: array(2) {
                    110:   [0]=>
                    111:   string(1) "."
                    112:   [1]=>
                    113:   string(2) ".."
                    114: }
                    115: 
                    116: -- Iteration 5 --
                    117: bool(true)
                    118: array(2) {
                    119:   [0]=>
                    120:   string(1) "."
                    121:   [1]=>
                    122:   string(2) ".."
                    123: }
                    124: 
                    125: -- Iteration 6 --
                    126: bool(true)
                    127: array(2) {
                    128:   [0]=>
                    129:   string(1) "."
                    130:   [1]=>
                    131:   string(2) ".."
                    132: }
                    133: 
                    134: -- Iteration 7 --
                    135: bool(true)
                    136: array(2) {
                    137:   [0]=>
                    138:   string(1) "."
                    139:   [1]=>
                    140:   string(2) ".."
                    141: }
                    142: 
                    143: -- Iteration 8 --
                    144: bool(true)
                    145: array(2) {
                    146:   [0]=>
                    147:   string(1) "."
                    148:   [1]=>
                    149:   string(2) ".."
                    150: }
                    151: 
                    152: -- Iteration 9 --
                    153: bool(true)
                    154: array(2) {
                    155:   [0]=>
                    156:   string(1) "."
                    157:   [1]=>
                    158:   string(2) ".."
                    159: }
                    160: 
                    161: -- Iteration 10 --
                    162: bool(true)
                    163: array(2) {
                    164:   [0]=>
                    165:   string(1) "."
                    166:   [1]=>
                    167:   string(2) ".."
                    168: }
                    169: ===DONE===

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