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