1--TEST-- 2Test nl_langinfo() function : unexpected inputs for '$tem' argument 3--SKIPIF-- 4<?php 5if( substr(PHP_OS, 0, 3) == 'WIN'){ 6 die('skip Not for Windows'); 7} 8?> 9--FILE-- 10<?php 11 12/* Prototype : string nl_langinfo ( int $item ) 13 * Description: Query language and locale information 14 * Source code: ext/standard/string.c 15*/ 16 17echo "*** Testing nl_langinfo() : with unexpected inputs for 'item' argument ***\n"; 18 19$original = setlocale(LC_ALL, 'C'); 20 21//get an unset variable 22$unset_var = 'string_val'; 23unset($unset_var); 24 25//defining a class 26class sample { 27 public function __toString() { 28 return "sample object"; 29 } 30} 31 32//getting the resource 33$file_handle = fopen(__FILE__, "r"); 34 35// array with different values for $input 36$items = array ( 37 38 // integer values 39/*1*/ 0, 40 10, 41 2147483647, 42 -2147483648, 43 44 // float values 45/*5*/ 10.5, 46 20.3, 47 -20.5, 48 10.1234567e5, 49 50 // array values 51/*9*/ array(), 52 array(0), 53 array(1, 2), 54 55 // boolean values 56/*12*/ true, 57 false, 58 TRUE, 59 FALSE, 60 61 // null vlaues 62/*16*/ NULL, 63 null, 64 65 // objects 66/*18*/ new sample(), 67 68 // resource 69/*19*/ $file_handle, 70 71 // undefined variable 72/*20*/ @$undefined_var, 73 74 // unset variable 75/*21*/ @$unset_var 76); 77 78//defining '$input' argument 79$input = "Test string"; 80 81// loop through with each element of the $items array to test nl_langinfo() function 82$count = 1; 83foreach($items as $item) { 84 echo "-- Iteration $count --\n"; 85 var_dump( nl_langinfo($item) ); 86 $count ++; 87} 88 89fclose($file_handle); //closing the file handle 90setlocale(LC_ALL, $original); 91 92?> 93===DONE=== 94--EXPECTF-- 95*** Testing nl_langinfo() : with unexpected inputs for 'item' argument *** 96-- Iteration 1 -- 97 98Warning: nl_langinfo(): Item '0' is not valid in %s on line %d 99bool(false) 100-- Iteration 2 -- 101 102Warning: nl_langinfo(): Item '10' is not valid in %s on line %d 103bool(false) 104-- Iteration 3 -- 105 106Warning: nl_langinfo(): Item '2147483647' is not valid in %s on line %d 107bool(false) 108-- Iteration 4 -- 109 110Warning: nl_langinfo(): Item '-2147483648' is not valid in %s on line %d 111bool(false) 112-- Iteration 5 -- 113 114Warning: nl_langinfo(): Item '10' is not valid in %s on line %d 115bool(false) 116-- Iteration 6 -- 117 118Warning: nl_langinfo(): Item '20' is not valid in %s on line %d 119bool(false) 120-- Iteration 7 -- 121 122Warning: nl_langinfo(): Item '-20' is not valid in %s on line %d 123bool(false) 124-- Iteration 8 -- 125 126Warning: nl_langinfo(): Item '1012345' is not valid in %s on line %d 127bool(false) 128-- Iteration 9 -- 129 130Warning: nl_langinfo() expects parameter 1 to be long, array given in %s on line %d 131NULL 132-- Iteration 10 -- 133 134Warning: nl_langinfo() expects parameter 1 to be long, array given in %s on line %d 135NULL 136-- Iteration 11 -- 137 138Warning: nl_langinfo() expects parameter 1 to be long, array given in %s on line %d 139NULL 140-- Iteration 12 -- 141 142Warning: nl_langinfo(): Item '1' is not valid in %s on line %d 143bool(false) 144-- Iteration 13 -- 145 146Warning: nl_langinfo(): Item '0' is not valid in %s on line %d 147bool(false) 148-- Iteration 14 -- 149 150Warning: nl_langinfo(): Item '1' is not valid in %s on line %d 151bool(false) 152-- Iteration 15 -- 153 154Warning: nl_langinfo(): Item '0' is not valid in %s on line %d 155bool(false) 156-- Iteration 16 -- 157 158Warning: nl_langinfo(): Item '0' is not valid in %s on line %d 159bool(false) 160-- Iteration 17 -- 161 162Warning: nl_langinfo(): Item '0' is not valid in %s on line %d 163bool(false) 164-- Iteration 18 -- 165 166Warning: nl_langinfo() expects parameter 1 to be long, object given in %s on line %d 167NULL 168-- Iteration 19 -- 169 170Warning: nl_langinfo() expects parameter 1 to be long, resource given in %s on line %d 171NULL 172-- Iteration 20 -- 173 174Warning: nl_langinfo(): Item '0' is not valid in %s on line %d 175bool(false) 176-- Iteration 21 -- 177 178Warning: nl_langinfo(): Item '0' is not valid in %s on line %d 179bool(false) 180===DONE=== 181