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

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

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