Annotation of embedaddon/php/ext/iconv/tests/iconv_mime_decode_headers_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test iconv_mime_encode() function : usage variations - Pass different data types to headers arg
3: --SKIPIF--
4: <?php
5: extension_loaded('iconv') or die('skip');
6: function_exists('iconv_mime_decode_headers') or die("skip iconv_mime_decode_headers() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : array iconv_mime_decode_headers(string headers [, int mode, string charset])
11: * Description: Decodes multiple mime header fields
12: * Source code: ext/iconv/iconv.c
13: */
14:
15: /*
16: * Pass different data types to $str argument to see how iconv_mime_decode_headers() behaves
17: */
18:
19: echo "*** Testing iconv_mime_decode_headers() : usage variations ***\n";
20:
21: // Initialise function arguments not being substituted
22: $headers = <<<EOF
23: Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=
24: To: example@example.com
25: Date: Thu, 1 Jan 1970 00:00:00 +0000
26: Message-Id: <example@example.com>
27: Received: from localhost (localhost [127.0.0.1]) by localhost
28: with SMTP id example for <example@example.com>;
29: Thu, 1 Jan 1970 00:00:00 +0000 (UTC)
30: (envelope-from example-return-0000-example=example.com@example.com)
31: Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
32:
33: EOF;
34:
35: $mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
36: $charset = 'ISO-8859-1';
37:
38:
39: //get an unset variable
40: $unset_var = 10;
41: unset ($unset_var);
42:
43: // get a class
44: class classA
45: {
46: public function __toString() {
47: return "Class A object";
48: }
49: }
50:
51: // heredoc string
52: $heredoc = <<<EOT
53: hello world
54: EOT;
55:
56: // get a resource variable
57: $fp = fopen(__FILE__, "r");
58:
59: // unexpected values to be passed to $str argument
60: $inputs = array(
61:
62: // int data
63: /*1*/ 0,
64: 1,
65: 12345,
66: -2345,
67:
68: // float data
69: /*5*/ 10.5,
70: -10.5,
71: 12.3456789000e10,
72: 12.3456789000E-10,
73: .5,
74:
75: // null data
76: /*10*/ NULL,
77: null,
78:
79: // boolean data
80: /*12*/ true,
81: false,
82: TRUE,
83: FALSE,
84:
85: // empty data
86: /*16*/ "",
87: '',
88:
89: // string data
90: /*18*/ "string",
91: 'string',
92: $heredoc,
93:
94: // object data
95: /*21*/ new classA(),
96:
97: // undefined data
98: /*22*/ @$undefined_var,
99:
100: // unset data
101: /*23*/ @$unset_var,
102:
103: // resource variable
104: /*24*/ $fp
105: );
106:
107: // loop through each element of $inputs to check the behavior of iconv_mime_decode_headers()
108: $iterator = 1;
109: foreach($inputs as $input) {
110: echo "\n-- Iteration $iterator --\n";
111: var_dump( iconv_mime_decode_headers($input, $mode, $charset));
112: $iterator++;
113: };
114:
115: fclose($fp);
116:
117: echo "Done";
118: ?>
119: --EXPECTF--
120: *** Testing iconv_mime_decode_headers() : usage variations ***
121:
122: -- Iteration 1 --
123: array(0) {
124: }
125:
126: -- Iteration 2 --
127: array(0) {
128: }
129:
130: -- Iteration 3 --
131: array(0) {
132: }
133:
134: -- Iteration 4 --
135: array(0) {
136: }
137:
138: -- Iteration 5 --
139: array(0) {
140: }
141:
142: -- Iteration 6 --
143: array(0) {
144: }
145:
146: -- Iteration 7 --
147: array(0) {
148: }
149:
150: -- Iteration 8 --
151: array(0) {
152: }
153:
154: -- Iteration 9 --
155: array(0) {
156: }
157:
158: -- Iteration 10 --
159: array(0) {
160: }
161:
162: -- Iteration 11 --
163: array(0) {
164: }
165:
166: -- Iteration 12 --
167: array(0) {
168: }
169:
170: -- Iteration 13 --
171: array(0) {
172: }
173:
174: -- Iteration 14 --
175: array(0) {
176: }
177:
178: -- Iteration 15 --
179: array(0) {
180: }
181:
182: -- Iteration 16 --
183: array(0) {
184: }
185:
186: -- Iteration 17 --
187: array(0) {
188: }
189:
190: -- Iteration 18 --
191: array(0) {
192: }
193:
194: -- Iteration 19 --
195: array(0) {
196: }
197:
198: -- Iteration 20 --
199: array(0) {
200: }
201:
202: -- Iteration 21 --
203: array(0) {
204: }
205:
206: -- Iteration 22 --
207: array(0) {
208: }
209:
210: -- Iteration 23 --
211: array(0) {
212: }
213:
214: -- Iteration 24 --
215:
216: Warning: iconv_mime_decode_headers() expects parameter 1 to be string, resource given in %s on line %d
217: bool(false)
218: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>