1--TEST-- 2Test 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 15echo "*** 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; 21unset ($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 70foreach($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 82echo "Done"; 83?> 84--EXPECTF-- 85*** Testing posix_getpwuid() : usage variations *** 86 87Notice: Undefined variable: undefined_var in %s on line %d 88 89Notice: Undefined variable: unset_var in %s on line %d 90 91Arg value 10.5 92valid output 93 94Arg value -10.5 95valid output 96 97Arg value 101234567000 98valid output 99 100Arg value 1.07654321E-9 101valid output 102 103Arg value 0.5 104valid output 105 106Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d 107 108Arg value Array 109 110Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d 111valid output 112 113Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d 114 115Arg value Array 116 117Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d 118valid output 119 120Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d 121 122Arg value Array 123 124Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d 125valid output 126 127Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d 128 129Arg value Array 130 131Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d 132valid output 133 134Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d 135 136Arg value Array 137 138Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d 139valid output 140 141Arg value 142valid output 143 144Arg value 145valid output 146 147Arg value 1 148valid output 149 150Arg value 151valid output 152 153Arg value 1 154valid output 155 156Arg value 157valid output 158 159Arg value 160 161Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d 162valid output 163 164Arg value 165 166Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d 167valid output 168 169Arg value string 170 171Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d 172valid output 173 174Arg value string 175 176Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d 177valid output 178 179Arg value 180valid output 181 182Arg value 183valid output 184 185Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d 186