Annotation of embedaddon/php/ext/posix/tests/posix_getpwuid_variation.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test posix_getpwuid() function : usage variations - parameter types
! 3: --SKIPIF--
! 4: <?php
! 5: if(!extension_loaded("posix")) print "skip - POSIX extension not loaded";
! 6: ?>
! 7: --FILE--
! 8: <?php
! 9: /* Prototype : proto array posix_getpwuid(long uid)
! 10: * Description: User database access (POSIX.1, 9.2.2)
! 11: * Source code: ext/posix/posix.c
! 12: * Alias to functions:
! 13: */
! 14:
! 15: echo "*** Testing posix_getpwuid() : usage variations ***\n";
! 16:
! 17: // Initialise function arguments not being substituted (if any)
! 18:
! 19: //get an unset variable
! 20: $unset_var = 10;
! 21: unset ($unset_var);
! 22:
! 23: //array of values to iterate over
! 24: $values = array(
! 25:
! 26: // float data
! 27: 10.5,
! 28: -10.5,
! 29: 10.1234567e10,
! 30: 10.7654321E-10,
! 31: .5,
! 32:
! 33: // array data
! 34: array(),
! 35: array(0),
! 36: array(1),
! 37: array(1, 2),
! 38: array('color' => 'red', 'item' => 'pen'),
! 39:
! 40: // null data
! 41: NULL,
! 42: null,
! 43:
! 44: // boolean data
! 45: true,
! 46: false,
! 47: TRUE,
! 48: FALSE,
! 49:
! 50: // empty data
! 51: "",
! 52: '',
! 53:
! 54: // string data
! 55: "string",
! 56: 'string',
! 57:
! 58: // undefined data
! 59: $undefined_var,
! 60:
! 61: // unset data
! 62: $unset_var,
! 63:
! 64: // object data
! 65: new stdclass(),
! 66: );
! 67:
! 68: // loop through each element of the array for uid
! 69:
! 70: foreach($values as $value) {
! 71: echo "\nArg value $value \n";
! 72: $result = posix_getpwuid($value);
! 73: if ((is_array($result) && (count($result) == 7))
! 74: ||
! 75: ($result === false)) {
! 76: echo "valid output\n";
! 77: } else {
! 78: var_dump($result);
! 79: }
! 80: };
! 81:
! 82: echo "Done";
! 83: ?>
! 84: --EXPECTF--
! 85: *** Testing posix_getpwuid() : usage variations ***
! 86:
! 87: Notice: Undefined variable: undefined_var in %s on line %d
! 88:
! 89: Notice: Undefined variable: unset_var in %s on line %d
! 90:
! 91: Arg value 10.5
! 92: valid output
! 93:
! 94: Arg value -10.5
! 95: valid output
! 96:
! 97: Arg value 101234567000
! 98: valid output
! 99:
! 100: Arg value 1.07654321E-9
! 101: valid output
! 102:
! 103: Arg value 0.5
! 104: valid output
! 105:
! 106: Arg value Array
! 107:
! 108: Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d
! 109: valid output
! 110:
! 111: Arg value Array
! 112:
! 113: Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d
! 114: valid output
! 115:
! 116: Arg value Array
! 117:
! 118: Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d
! 119: valid output
! 120:
! 121: Arg value Array
! 122:
! 123: Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d
! 124: valid output
! 125:
! 126: Arg value Array
! 127:
! 128: Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d
! 129: valid output
! 130:
! 131: Arg value
! 132: valid output
! 133:
! 134: Arg value
! 135: valid output
! 136:
! 137: Arg value 1
! 138: valid output
! 139:
! 140: Arg value
! 141: valid output
! 142:
! 143: Arg value 1
! 144: valid output
! 145:
! 146: Arg value
! 147: valid output
! 148:
! 149: Arg value
! 150:
! 151: Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d
! 152: valid output
! 153:
! 154: Arg value
! 155:
! 156: Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d
! 157: valid output
! 158:
! 159: Arg value string
! 160:
! 161: Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d
! 162: valid output
! 163:
! 164: Arg value string
! 165:
! 166: Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d
! 167: valid output
! 168:
! 169: Arg value
! 170: valid output
! 171:
! 172: Arg value
! 173: valid output
! 174:
! 175: Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>