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		  // integer values
38/*1*/	  2147483647,
39		  -2147483648,
40		  -20,
41
42	      // array values
43/*4*/	  array(),
44		  array(0),
45		  array(1, 2),
46
47		  // objects
48/*7*/	  new sample(),
49
50		  // resource
51/*8*/	  $file_handle,
52		);
53
54//defining '$input' argument
55$input = "Test string";
56
57// loop through with each element of the $items array to test nl_langinfo() function
58$count = 1;
59foreach($items as $item) {
60  echo "-- Iteration $count --\n";
61  var_dump( nl_langinfo($item) );
62  $count ++;
63}
64
65fclose($file_handle);  //closing the file handle
66setlocale(LC_ALL, $original);
67
68?>
69===DONE===
70--EXPECTF--
71*** Testing nl_langinfo() : with unexpected inputs for 'item' argument ***
72-- Iteration 1 --
73
74Warning: nl_langinfo(): Item '2147483647' is not valid in %s on line %d
75bool(false)
76-- Iteration 2 --
77
78Warning: nl_langinfo(): Item '-2147483648' is not valid in %s on line %d
79bool(false)
80-- Iteration 3 --
81
82Warning: nl_langinfo(): Item '-20' is not valid in %s on line %d
83bool(false)
84-- Iteration 4 --
85
86Warning: nl_langinfo() expects parameter 1 to be integer, array given in %s on line %d
87NULL
88-- Iteration 5 --
89
90Warning: nl_langinfo() expects parameter 1 to be integer, array given in %s on line %d
91NULL
92-- Iteration 6 --
93
94Warning: nl_langinfo() expects parameter 1 to be integer, array given in %s on line %d
95NULL
96-- Iteration 7 --
97
98Warning: nl_langinfo() expects parameter 1 to be integer, object given in %s on line %d
99NULL
100-- Iteration 8 --
101
102Warning: nl_langinfo() expects parameter 1 to be integer, resource given in %s on line %d
103NULL
104===DONE===
105