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

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

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