Annotation of embedaddon/php/ext/standard/tests/dir/scandir_variation3.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test scandir() function : usage variations - diff data types as $context arg
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
                      6:  * Description: List files & directories inside the specified path 
                      7:  * Source code: ext/standard/dir.c
                      8:  */
                      9: 
                     10: /*
                     11:  * Pass different data types as $context argument to test how scandir() behaves
                     12:  */
                     13: 
                     14: echo "*** Testing scandir() : usage variations ***\n";
                     15: 
                     16: // Initialise function arguments not being substituted
                     17: $dir = dirname(__FILE__) . '/scandir_variation3';
                     18: mkdir($dir);
1.1.1.2 ! misho      19: $sorting_order = SCANDIR_SORT_ASCENDING;
1.1       misho      20: 
                     21: //get an unset variable
                     22: $unset_var = 10;
                     23: unset ($unset_var);
                     24: 
                     25: // get a class
                     26: class classA
                     27: {
                     28:   public function __toString() {
                     29:     return "Class A object";
                     30:   }
                     31: }
                     32: 
                     33: // heredoc string
                     34: $heredoc = <<<EOT
                     35: hello world
                     36: EOT;
                     37: 
                     38: // get a resource variable
                     39: $fp = fopen(__FILE__, "r");
                     40: 
                     41: // unexpected values to be passed to $context argument
                     42: $inputs = array(
                     43: 
                     44:        // int data
                     45: /*1*/  0,
                     46:        1,
                     47:        12345,
                     48:        -2345,
                     49: 
                     50:        // float data
                     51: /*5*/  10.5,
                     52:        -10.5,
                     53:        12.3456789000e10,
                     54:        12.3456789000E-10,
                     55:        .5,
                     56: 
                     57:        // null data
                     58: /*10*/ NULL,
                     59:        null,
                     60: 
                     61:        // boolean data
                     62: /*12*/ true,
                     63:        false,
                     64:        TRUE,
                     65:        FALSE,
                     66:        
                     67:        // empty data
                     68: /*16*/ "",
                     69:        '',
                     70:        array(),
                     71: 
                     72:        // string data
                     73: /*19*/ "string",
                     74:        'string',
                     75:        $heredoc,
                     76:        
                     77:        // object data
                     78: /*22*/ new classA(),
                     79: 
                     80:        // undefined data
                     81: /*23*/ @$undefined_var,
                     82: 
                     83:        // unset data
                     84: /*24*/ @$unset_var,
                     85: 
                     86:        // resource variable
                     87: /*25*/ $fp
                     88: );
                     89: 
                     90: // loop through each element of $inputs to check the behavior of scandir()
                     91: $iterator = 1;
                     92: foreach($inputs as $input) {
                     93:   echo "\n-- Iteration $iterator --\n";
                     94:   var_dump( scandir($dir, $sorting_order, $input) );
                     95:   $iterator++;
                     96: };
                     97: 
                     98: fclose($fp);
                     99: ?>
                    100: ===DONE===
                    101: --CLEAN--
                    102: <?php
                    103: $dir = dirname(__FILE__) . '/scandir_variation3';
                    104: rmdir($dir);
                    105: ?>
                    106: --EXPECTF--
                    107: *** Testing scandir() : usage variations ***
                    108: 
                    109: -- Iteration 1 --
                    110: 
                    111: Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
                    112: NULL
                    113: 
                    114: -- Iteration 2 --
                    115: 
                    116: Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
                    117: NULL
                    118: 
                    119: -- Iteration 3 --
                    120: 
                    121: Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
                    122: NULL
                    123: 
                    124: -- Iteration 4 --
                    125: 
                    126: Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
                    127: NULL
                    128: 
                    129: -- Iteration 5 --
                    130: 
                    131: Warning: scandir() expects parameter 3 to be resource, double given in %s on line %d
                    132: NULL
                    133: 
                    134: -- Iteration 6 --
                    135: 
                    136: Warning: scandir() expects parameter 3 to be resource, double given in %s on line %d
                    137: NULL
                    138: 
                    139: -- Iteration 7 --
                    140: 
                    141: Warning: scandir() expects parameter 3 to be resource, double given in %s on line %d
                    142: NULL
                    143: 
                    144: -- Iteration 8 --
                    145: 
                    146: Warning: scandir() expects parameter 3 to be resource, double given in %s on line %d
                    147: NULL
                    148: 
                    149: -- Iteration 9 --
                    150: 
                    151: Warning: scandir() expects parameter 3 to be resource, double given in %s on line %d
                    152: NULL
                    153: 
                    154: -- Iteration 10 --
                    155: 
                    156: Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
                    157: NULL
                    158: 
                    159: -- Iteration 11 --
                    160: 
                    161: Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
                    162: NULL
                    163: 
                    164: -- Iteration 12 --
                    165: 
                    166: Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
                    167: NULL
                    168: 
                    169: -- Iteration 13 --
                    170: 
                    171: Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
                    172: NULL
                    173: 
                    174: -- Iteration 14 --
                    175: 
                    176: Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
                    177: NULL
                    178: 
                    179: -- Iteration 15 --
                    180: 
                    181: Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
                    182: NULL
                    183: 
                    184: -- Iteration 16 --
                    185: 
                    186: Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
                    187: NULL
                    188: 
                    189: -- Iteration 17 --
                    190: 
                    191: Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
                    192: NULL
                    193: 
                    194: -- Iteration 18 --
                    195: 
                    196: Warning: scandir() expects parameter 3 to be resource, array given in %s on line %d
                    197: NULL
                    198: 
                    199: -- Iteration 19 --
                    200: 
                    201: Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
                    202: NULL
                    203: 
                    204: -- Iteration 20 --
                    205: 
                    206: Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
                    207: NULL
                    208: 
                    209: -- Iteration 21 --
                    210: 
                    211: Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
                    212: NULL
                    213: 
                    214: -- Iteration 22 --
                    215: 
                    216: Warning: scandir() expects parameter 3 to be resource, object given in %s on line %d
                    217: NULL
                    218: 
                    219: -- Iteration 23 --
                    220: 
                    221: Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
                    222: NULL
                    223: 
                    224: -- Iteration 24 --
                    225: 
                    226: Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
                    227: NULL
                    228: 
                    229: -- Iteration 25 --
                    230: 
                    231: Warning: scandir(): supplied resource is not a valid Stream-Context resource in %s on line %d
                    232: array(2) {
                    233:   [0]=>
                    234:   string(1) "."
                    235:   [1]=>
                    236:   string(2) ".."
                    237: }
                    238: ===DONE===

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