Annotation of embedaddon/php/ext/standard/tests/dir/readdir_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test readdir() function : usage variations - different data types as $dir_handle arg
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : string readdir([resource $dir_handle])
! 6: * Description: Read directory entry from dir_handle
! 7: * Source code: ext/standard/dir.c
! 8: */
! 9:
! 10: /*
! 11: * Pass different data types as $dir_handle argument to readdir() to test behaviour
! 12: */
! 13:
! 14: echo "*** Testing readdir() : 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: // unexpected values to be passed to $dir_handle argument
! 34: $inputs = array(
! 35:
! 36: // int data
! 37: /*1*/ 0,
! 38: 1,
! 39: 12345,
! 40: -2345,
! 41:
! 42: // float data
! 43: /*5*/ 10.5,
! 44: -10.5,
! 45: 12.3456789000e10,
! 46: 12.3456789000E-10,
! 47: .5,
! 48:
! 49: // null data
! 50: /*10*/ NULL,
! 51: null,
! 52:
! 53: // boolean data
! 54: /*12*/ true,
! 55: false,
! 56: TRUE,
! 57: FALSE,
! 58:
! 59: // empty data
! 60: /*16*/ "",
! 61: '',
! 62: array(),
! 63:
! 64: // string data
! 65: /*19*/ "string",
! 66: 'string',
! 67: $heredoc,
! 68:
! 69: // object data
! 70: /*22*/ new classA(),
! 71:
! 72: // undefined data
! 73: /*23*/ @$undefined_var,
! 74:
! 75: // unset data
! 76: /*24*/ @$unset_var,
! 77: );
! 78:
! 79: // loop through each element of $inputs to check the behavior of readdir()
! 80: $iterator = 1;
! 81: foreach($inputs as $input) {
! 82: echo "\n-- Iteration $iterator --\n";
! 83: var_dump( readdir($input) );
! 84: $iterator++;
! 85: };
! 86: ?>
! 87: ===DONE===
! 88: --EXPECTF--
! 89: *** Testing readdir() : usage variations ***
! 90:
! 91: -- Iteration 1 --
! 92:
! 93: Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
! 94: NULL
! 95:
! 96: -- Iteration 2 --
! 97:
! 98: Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
! 99: NULL
! 100:
! 101: -- Iteration 3 --
! 102:
! 103: Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
! 104: NULL
! 105:
! 106: -- Iteration 4 --
! 107:
! 108: Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
! 109: NULL
! 110:
! 111: -- Iteration 5 --
! 112:
! 113: Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
! 114: NULL
! 115:
! 116: -- Iteration 6 --
! 117:
! 118: Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
! 119: NULL
! 120:
! 121: -- Iteration 7 --
! 122:
! 123: Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
! 124: NULL
! 125:
! 126: -- Iteration 8 --
! 127:
! 128: Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
! 129: NULL
! 130:
! 131: -- Iteration 9 --
! 132:
! 133: Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
! 134: NULL
! 135:
! 136: -- Iteration 10 --
! 137:
! 138: Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
! 139: NULL
! 140:
! 141: -- Iteration 11 --
! 142:
! 143: Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
! 144: NULL
! 145:
! 146: -- Iteration 12 --
! 147:
! 148: Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
! 149: NULL
! 150:
! 151: -- Iteration 13 --
! 152:
! 153: Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
! 154: NULL
! 155:
! 156: -- Iteration 14 --
! 157:
! 158: Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
! 159: NULL
! 160:
! 161: -- Iteration 15 --
! 162:
! 163: Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
! 164: NULL
! 165:
! 166: -- Iteration 16 --
! 167:
! 168: Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d
! 169: NULL
! 170:
! 171: -- Iteration 17 --
! 172:
! 173: Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d
! 174: NULL
! 175:
! 176: -- Iteration 18 --
! 177:
! 178: Warning: readdir() expects parameter 1 to be resource, array given in %s on line %d
! 179: NULL
! 180:
! 181: -- Iteration 19 --
! 182:
! 183: Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d
! 184: NULL
! 185:
! 186: -- Iteration 20 --
! 187:
! 188: Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d
! 189: NULL
! 190:
! 191: -- Iteration 21 --
! 192:
! 193: Warning: readdir() expects parameter 1 to be resource, string given in %s on line %d
! 194: NULL
! 195:
! 196: -- Iteration 22 --
! 197:
! 198: Warning: readdir() expects parameter 1 to be resource, object given in %s on line %d
! 199: NULL
! 200:
! 201: -- Iteration 23 --
! 202:
! 203: Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
! 204: NULL
! 205:
! 206: -- Iteration 24 --
! 207:
! 208: Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
! 209: NULL
! 210: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>