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

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

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