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