1--TEST--
2Test money_format() function :  usage variations - test values for $format argument
3--SKIPIF--
4<?php
5	if (!function_exists('money_format')) {
6		die("SKIP money_format - not supported\n");
7	}
8?>
9--FILE--
10<?php
11/* Prototype  : string money_format  ( string $format  , float $number  )
12 * Description: Formats a number as a currency string
13 * Source code: ext/standard/string.c
14*/
15
16// ===========================================================================================
17// = We do not test for exact return-values, as those might be different between OS-versions =
18// ===========================================================================================
19
20echo "*** Testing money_format() function: with unexpected inputs for 'format' argument ***\n";
21
22//get an unset variable
23$unset_var = '  string_val  ';
24unset($unset_var);
25
26//defining a couple of sample classes
27class class_no_tostring  {
28}
29
30class class_with_tostring  {
31  public function __toString() {
32    return "  sample object  ";
33  }
34}
35
36
37//getting the resource
38$file_handle = fopen(__FILE__, "r");
39
40// array with different values for $input
41$formats =  array (
42
43		  // integer values
44/*1*/	  0,
45		  1,
46		  255,
47		  256,
48	      2147483647,
49		  -2147483648,
50
51		  // float values
52/*7*/	  10.5,
53		  -20.5,
54		  10.1234567e10,
55
56		  // array values
57/*10*/	  array(),
58		  array(0),
59		  array(1, 2),
60
61		  // boolean values
62/*13*/	  true,
63		  false,
64		  TRUE,
65		  FALSE,
66
67		  // null values
68/*17*/	  NULL,
69		  null,
70
71		  // string values
72/*19*/	  "abcd",
73		  'abcd',
74		  "0x12f",
75		  "%=*!14#8.2nabcd",
76
77		  // objects
78/*23*/	  new class_no_tostring(),
79		  new class_with_tostring(),
80
81		  // resource
82/*25*/	  $file_handle,
83
84		  // undefined variable
85/*26*/	  @$undefined_var,
86
87		  // unset variable
88/*27*/	  @$unset_var
89);
90
91// loop through with each element of the $formats array to test money_format() function
92$count = 1;
93$value = 1234.56;
94
95foreach($formats as $format) {
96  echo "-- Iteration $count --\n";
97  echo gettype(money_format($format, $value))."\n";
98  $count ++;
99}
100
101// close the file handle
102fclose($file_handle);
103
104?>
105===Done===
106--EXPECTF--
107*** Testing money_format() function: with unexpected inputs for 'format' argument ***
108-- Iteration 1 --
109string
110-- Iteration 2 --
111string
112-- Iteration 3 --
113string
114-- Iteration 4 --
115string
116-- Iteration 5 --
117string
118-- Iteration 6 --
119string
120-- Iteration 7 --
121string
122-- Iteration 8 --
123string
124-- Iteration 9 --
125string
126-- Iteration 10 --
127
128Warning: money_format() expects parameter 1 to be string, array given in %s on line %d
129NULL
130-- Iteration 11 --
131
132Warning: money_format() expects parameter 1 to be string, array given in %s on line %d
133NULL
134-- Iteration 12 --
135
136Warning: money_format() expects parameter 1 to be string, array given in %s on line %d
137NULL
138-- Iteration 13 --
139string
140-- Iteration 14 --
141string
142-- Iteration 15 --
143string
144-- Iteration 16 --
145string
146-- Iteration 17 --
147string
148-- Iteration 18 --
149string
150-- Iteration 19 --
151string
152-- Iteration 20 --
153string
154-- Iteration 21 --
155string
156-- Iteration 22 --
157string
158-- Iteration 23 --
159
160Warning: money_format() expects parameter 1 to be string, object given in %s on line %d
161NULL
162-- Iteration 24 --
163string
164-- Iteration 25 --
165
166Warning: money_format() expects parameter 1 to be string, resource given in %s on line %d
167NULL
168-- Iteration 26 --
169string
170-- Iteration 27 --
171string
172===Done===
173