1--TEST--
2Test mb_strtoupper() function : usage varitations - pass different data types as $sourcestring arg
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_strtoupper') or die("skip mb_strtoupper() is not available in this build");
7?>
8--FILE--
9<?php
10/* Prototype  : string mb_strtoupper(string $sourcestring [, string $encoding]
11 * Description: Returns a uppercased version of $sourcestring
12 * Source code: ext/mbstring/mbstring.c
13 */
14
15/*
16 *
17 * Pass different data types as $sourcestring argument to mb_strtoupper to test behaviour
18 */
19
20echo "*** Testing mb_strtoupper() : usage variations ***\n";
21
22// Initialise function arguments not being substituted
23
24//get an unset variable
25$unset_var = 10;
26unset ($unset_var);
27
28// get a class
29class classA
30{
31  public function __toString() {
32    return "Class A object";
33  }
34}
35
36// heredoc string
37$heredoc = <<<EOT
38Hello, World
39EOT;
40
41// get a resource variable
42$fp = fopen(__FILE__, "r");
43
44// unexpected values to be passed to $sourcestring argument
45$inputs = array(
46
47       // int data
48/*1*/  0,
49       1,
50       12345,
51       -2345,
52
53       // float data
54/*5*/  10.5,
55       -10.5,
56       12.3456789000e10,
57       12.3456789000E-10,
58       .5,
59
60       // null data
61/*10*/ NULL,
62       null,
63
64       // boolean data
65/*12*/ true,
66       false,
67       TRUE,
68       FALSE,
69
70       // empty data
71/*16*/ "",
72       '',
73
74       // string data
75/*18*/ "String",
76       'String',
77       $heredoc,
78
79       // object data
80/*21*/ new classA(),
81
82       // undefined data
83/*22*/ @$undefined_var,
84
85       // unset data
86/*23*/ @$unset_var,
87
88       // resource variable
89/*24*/ $fp
90);
91
92// loop through each element of $inputs to check the behavior of mb_strtoupper()
93$iterator = 1;
94foreach($inputs as $input) {
95  echo "\n-- Iteration $iterator --\n";
96  var_dump( mb_strtoupper($input) );
97  $iterator++;
98};
99
100fclose($fp);
101
102echo "Done";
103?>
104--EXPECTF--
105*** Testing mb_strtoupper() : usage variations ***
106
107-- Iteration 1 --
108string(1) "0"
109
110-- Iteration 2 --
111string(1) "1"
112
113-- Iteration 3 --
114string(5) "12345"
115
116-- Iteration 4 --
117string(5) "-2345"
118
119-- Iteration 5 --
120string(4) "10.5"
121
122-- Iteration 6 --
123string(5) "-10.5"
124
125-- Iteration 7 --
126string(12) "123456789000"
127
128-- Iteration 8 --
129string(13) "1.23456789E-9"
130
131-- Iteration 9 --
132string(3) "0.5"
133
134-- Iteration 10 --
135string(0) ""
136
137-- Iteration 11 --
138string(0) ""
139
140-- Iteration 12 --
141string(1) "1"
142
143-- Iteration 13 --
144string(0) ""
145
146-- Iteration 14 --
147string(1) "1"
148
149-- Iteration 15 --
150string(0) ""
151
152-- Iteration 16 --
153string(0) ""
154
155-- Iteration 17 --
156string(0) ""
157
158-- Iteration 18 --
159string(6) "STRING"
160
161-- Iteration 19 --
162string(6) "STRING"
163
164-- Iteration 20 --
165string(12) "HELLO, WORLD"
166
167-- Iteration 21 --
168string(14) "CLASS A OBJECT"
169
170-- Iteration 22 --
171string(0) ""
172
173-- Iteration 23 --
174string(0) ""
175
176-- Iteration 24 --
177
178Warning: mb_strtoupper() expects parameter 1 to be string, resource given in %s on line %d
179NULL
180Done
181