Add support for i8
[plcapi.git] / tests / 1ParsingBugsTest.php
1 <?php
2 /**
3  * NB: do not let your IDE fool you. The correct encoding for this file is NOT UTF8.
4  */
5 include_once __DIR__ . '/../lib/xmlrpc.inc';
6 include_once __DIR__ . '/../lib/xmlrpcs.inc';
7
8 include_once __DIR__ . '/parse_args.php';
9
10 /**
11  * Tests involving parsing of xml and handling of xmlrpc values
12  */
13 class ParsingBugsTests extends PHPUnit_Framework_TestCase
14 {
15     public $args = array();
16
17     protected function setUp()
18     {
19         $this->args = argParser::getArgs();
20         if ($this->args['DEBUG'] == 1)
21             ob_start();
22     }
23
24     protected function tearDown()
25     {
26         if ($this->args['DEBUG'] != 1)
27             return;
28         $out = ob_get_clean();
29         $status = $this->getStatus();
30         if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR
31             || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
32             echo $out;
33         }
34     }
35
36     protected function newMsg($methodName, $params = array())
37     {
38         $msg = new xmlrpcmsg($methodName, $params);
39         $msg->setDebug($this->args['DEBUG']);
40         return $msg;
41     }
42
43     public function testMinusOneString()
44     {
45         $v = new xmlrpcval('-1');
46         $u = new xmlrpcval('-1', 'string');
47         $t = new xmlrpcval(-1, 'string');
48         $this->assertEquals($v->scalarval(), $u->scalarval());
49         $this->assertEquals($v->scalarval(), $t->scalarval());
50     }
51
52     /**
53      * This looks funny, and we might call it a bug. But we strive for 100 backwards compat...
54      */
55     public function testMinusOneInt()
56     {
57         $u = new xmlrpcval();
58         $v = new xmlrpcval(-1);
59         $this->assertEquals($u->scalarval(), $v->scalarval());
60     }
61
62     public function testUnicodeInMemberName()
63     {
64         $str = "G" . chr(252) . "nter, El" . chr(232) . "ne";
65         $v = array($str => new xmlrpcval(1));
66         $r = new xmlrpcresp(new xmlrpcval($v, 'struct'));
67         $r = $r->serialize();
68         $m = $this->newMsg('dummy');
69         $r = $m->parseResponse($r);
70         $v = $r->value();
71         $this->assertEquals(true, $v->structmemexists($str));
72     }
73
74     public function testUnicodeInErrorString()
75     {
76         $response = utf8_encode(
77             '<?xml version="1.0"?>
78 <!-- $Id -->
79 <!-- found by G. giunta, covers what happens when lib receives
80   UTF8 chars in response text and comments -->
81 <!-- ' . chr(224) . chr(252) . chr(232) . '&#224;&#252;&#232; -->
82 <methodResponse>
83 <fault>
84 <value>
85 <struct>
86 <member>
87 <name>faultCode</name>
88 <value><int>888</int></value>
89 </member>
90 <member>
91 <name>faultString</name>
92 <value><string>' . chr(224) . chr(252) . chr(232) . '&#224;&#252;&#232;</string></value>
93 </member>
94 </struct>
95 </value>
96 </fault>
97 </methodResponse>');
98         $m = $this->newMsg('dummy');
99         $r = $m->parseResponse($response);
100         $v = $r->faultString();
101         $this->assertEquals(chr(224) . chr(252) . chr(232) . chr(224) . chr(252) . chr(232), $v);
102     }
103
104     public function testValidNumbers()
105     {
106         $m = $this->newMsg('dummy');
107         $fp =
108             '<?xml version="1.0"?>
109 <methodResponse>
110 <params>
111 <param>
112 <value>
113 <struct>
114 <member>
115 <name>integer1</name>
116 <value><int>01</int></value>
117 </member>
118 <member>
119 <name>integer2</name>
120 <value><int>+1</int></value>
121 </member>
122 <member>
123 <name>integer3</name>
124 <value><i4>1</i4></value>
125 </member>
126 <member>
127 <name>float1</name>
128 <value><double>01.10</double></value>
129 </member>
130 <member>
131 <name>float2</name>
132 <value><double>+1.10</double></value>
133 </member>
134 <member>
135 <name>float3</name>
136 <value><double>-1.10e2</double></value>
137 </member>
138 </struct>
139 </value>
140 </param>
141 </params>
142 </methodResponse>';
143         $r = $m->parseResponse($fp);
144         $v = $r->value();
145         $s = $v->structmem('integer1');
146         $t = $v->structmem('integer2');
147         $u = $v->structmem('integer3');
148         $x = $v->structmem('float1');
149         $y = $v->structmem('float2');
150         $z = $v->structmem('float3');
151         $this->assertEquals(1, $s->scalarval());
152         $this->assertEquals(1, $t->scalarval());
153         $this->assertEquals(1, $u->scalarval());
154
155         $this->assertEquals(1.1, $x->scalarval());
156         $this->assertEquals(1.1, $y->scalarval());
157         $this->assertEquals(-110.0, $z->scalarval());
158     }
159
160     public function testI8()
161     {
162         if (PHP_INT_SIZE == 4 ) {
163             $this->markTestSkipped('did not find a locale which sets decimal separator to comma');
164             return;
165         }
166
167         $m = $this->newMsg('dummy');
168         $fp =
169             '<?xml version="1.0"?>
170 <methodResponse>
171 <params>
172 <param>
173 <value>
174 <struct>
175 <member>
176 <name>integer1</name>
177 <value><i8>1</i8></value>
178 </member>
179 </member>
180 </struct>
181 </value>
182 </param>
183 </params>
184 </methodResponse>';
185         $r = $m->parseResponse($fp);
186         $v = $r->value();
187         $s = $v->structmem('integer1');
188         $this->assertEquals(1, $s->scalarval());
189     }
190
191     public function testAddScalarToStruct()
192     {
193         $v = new xmlrpcval(array('a' => 'b'), 'struct');
194         // use @ operator in case error_log gets on screen
195         $r = @$v->addscalar('c');
196         $this->assertEquals(0, $r);
197     }
198
199     public function testAddStructToStruct()
200     {
201         $v = new xmlrpcval(array('a' => new xmlrpcval('b')), 'struct');
202         $r = $v->addstruct(array('b' => new xmlrpcval('c')));
203         $this->assertEquals(2, $v->structsize());
204         $this->assertEquals(1, $r);
205         $r = $v->addstruct(array('b' => new xmlrpcval('b')));
206         $this->assertEquals(2, $v->structsize());
207     }
208
209     public function testAddArrayToArray()
210     {
211         $v = new xmlrpcval(array(new xmlrpcval('a'), new xmlrpcval('b')), 'array');
212         $r = $v->addarray(array(new xmlrpcval('b'), new xmlrpcval('c')));
213         $this->assertEquals(4, $v->arraysize());
214         $this->assertEquals(1, $r);
215     }
216
217     public function testEncodeArray()
218     {
219         $r = range(1, 100);
220         $v = php_xmlrpc_encode($r);
221         $this->assertEquals('array', $v->kindof());
222     }
223
224     public function testEncodeRecursive()
225     {
226         $v = php_xmlrpc_encode(php_xmlrpc_encode('a simple string'));
227         $this->assertEquals('scalar', $v->kindof());
228     }
229
230     public function testBrokenRequests()
231     {
232         $s = new xmlrpc_server();
233         // omitting the 'params' tag: not tolerated by the lib anymore
234         $f = '<?xml version="1.0"?>
235 <methodCall>
236 <methodName>system.methodHelp</methodName>
237 <param>
238 <value><string>system.methodHelp</string></value>
239 </param>
240 </methodCall>';
241         $r = $s->parserequest($f);
242         $this->assertEquals(15, $r->faultCode());
243         // omitting a 'param' tag
244         $f = '<?xml version="1.0"?>
245 <methodCall>
246 <methodName>system.methodHelp</methodName>
247 <params>
248 <value><string>system.methodHelp</string></value>
249 </params>
250 </methodCall>';
251         $r = $s->parserequest($f);
252         $this->assertEquals(15, $r->faultCode());
253         // omitting a 'value' tag
254         $f = '<?xml version="1.0"?>
255 <methodCall>
256 <methodName>system.methodHelp</methodName>
257 <params>
258 <param><string>system.methodHelp</string></param>
259 </params>
260 </methodCall>';
261         $r = $s->parserequest($f);
262         $this->assertEquals(15, $r->faultCode());
263     }
264
265     public function testBrokenResponses()
266     {
267         $m = $this->newMsg('dummy');
268         // omitting the 'params' tag: no more tolerated by the lib...
269         $f = '<?xml version="1.0"?>
270 <methodResponse>
271 <param>
272 <value><string>system.methodHelp</string></value>
273 </param>
274 </methodResponse>';
275         $r = $m->parseResponse($f);
276         $this->assertEquals(2, $r->faultCode());
277         // omitting the 'param' tag: no more tolerated by the lib...
278         $f = '<?xml version="1.0"?>
279 <methodResponse>
280 <params>
281 <value><string>system.methodHelp</string></value>
282 </params>
283 </methodResponse>';
284         $r = $m->parseResponse($f);
285         $this->assertEquals(2, $r->faultCode());
286         // omitting a 'value' tag: KO
287         $f = '<?xml version="1.0"?>
288 <methodResponse>
289 <params>
290 <param><string>system.methodHelp</string></param>
291 </params>
292 </methodResponse>';
293         $r = $m->parseResponse($f);
294         $this->assertEquals(2, $r->faultCode());
295     }
296
297     public function testBuggyHttp()
298     {
299         $s = $this->newMsg('dummy');
300         $f = 'HTTP/1.1 100 Welcome to the jungle
301
302 HTTP/1.0 200 OK
303 X-Content-Marx-Brothers: Harpo
304         Chico and Groucho
305 Content-Length: who knows?
306
307
308
309 <?xml version="1.0"?>
310 <!-- First of all, let\'s check out if the lib properly handles a commented </methodResponse> tag... -->
311 <methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
312 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
313
314
315 and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
316 <script type="text\javascript">document.write(\'Hello, my name is added nag, I\\\'m happy to serve your content for free\');</script>
317  ';
318         $r = $s->parseResponse($f);
319         $v = $r->value();
320         $s = $v->structmem('content');
321         $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
322     }
323
324     public function testStringBug()
325     {
326         $s = $this->newMsg('dummy');
327         $f = '<?xml version="1.0"?>
328 <!-- $Id -->
329 <!-- found by 2z69xks7bpy001@sneakemail.com, amongst others
330  covers what happens when there\'s character data after </string>
331  and before </value> -->
332 <methodResponse>
333 <params>
334 <param>
335 <value>
336 <struct>
337 <member>
338 <name>success</name>
339 <value>
340 <boolean>1</boolean>
341 </value>
342 </member>
343 <member>
344 <name>sessionID</name>
345 <value>
346 <string>S300510007I</string>
347 </value>
348 </member>
349 </struct>
350 </value>
351 </param>
352 </params>
353 </methodResponse> ';
354         $r = $s->parseResponse($f);
355         $v = $r->value();
356         $s = $v->structmem('sessionID');
357         $this->assertEquals('S300510007I', $s->scalarval());
358     }
359
360     public function testWhiteSpace()
361     {
362         $s = $this->newMsg('dummy');
363         $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
364 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
365
366
367 and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
368 ';
369         $r = $s->parseResponse($f);
370         $v = $r->value();
371         $s = $v->structmem('content');
372         $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
373     }
374
375     public function testDoubleDataInArrayTag()
376     {
377         $s = $this->newMsg('dummy');
378         $f = '<?xml version="1.0"?><methodResponse><params><param><value><array>
379 <data></data>
380 <data></data>
381 </array></value></param></params></methodResponse>
382 ';
383         $r = $s->parseResponse($f);
384         $v = $r->faultCode();
385         $this->assertEquals(2, $v);
386         $f = '<?xml version="1.0"?><methodResponse><params><param><value><array>
387 <data><value>Hello world</value></data>
388 <data></data>
389 </array></value></param></params></methodResponse>
390 ';
391         $r = $s->parseResponse($f);
392         $v = $r->faultCode();
393         $this->assertEquals(2, $v);
394     }
395
396     public function testDoubleStuffInValueTag()
397     {
398         $s = $this->newMsg('dummy');
399         $f = '<?xml version="1.0"?><methodResponse><params><param><value>
400 <string>hello world</string>
401 <array><data></data></array>
402 </value></param></params></methodResponse>
403 ';
404         $r = $s->parseResponse($f);
405         $v = $r->faultCode();
406         $this->assertEquals(2, $v);
407         $f = '<?xml version="1.0"?><methodResponse><params><param><value>
408 <string>hello</string>
409 <string>world</string>
410 </value></param></params></methodResponse>
411 ';
412         $r = $s->parseResponse($f);
413         $v = $r->faultCode();
414         $this->assertEquals(2, $v);
415         $f = '<?xml version="1.0"?><methodResponse><params><param><value>
416 <string>hello</string>
417 <struct><member><name>hello><value>world</value></member></struct>
418 </value></param></params></methodResponse>
419 ';
420         $r = $s->parseResponse($f);
421         $v = $r->faultCode();
422         $this->assertEquals(2, $v);
423     }
424
425     public function testAutodecodeResponse()
426     {
427         $s = $this->newMsg('dummy');
428         $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
429 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
430
431
432 and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
433 ';
434         $r = $s->parseResponse($f, true, 'phpvals');
435         $v = $r->value();
436         $s = $v['content'];
437         $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s);
438     }
439
440     public function testNoDecodeResponse()
441     {
442         $s = $this->newMsg('dummy');
443         $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
444 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
445
446
447 and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>';
448         $r = $s->parseResponse($f, true, 'xml');
449         $v = $r->value();
450         $this->assertEquals($f, $v);
451     }
452
453     public function testAutoCoDec()
454     {
455         $data1 = array(1, 1.0, 'hello world', true, '20051021T23:43:00', -1, 11.0, '~!@#$%^&*()_+|', false, '20051021T23:43:00');
456         $data2 = array('zero' => $data1, 'one' => $data1, 'two' => $data1, 'three' => $data1, 'four' => $data1, 'five' => $data1, 'six' => $data1, 'seven' => $data1, 'eight' => $data1, 'nine' => $data1);
457         $data = array($data2, $data2, $data2, $data2, $data2, $data2, $data2, $data2, $data2, $data2);
458         //$keys = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
459         $v1 = php_xmlrpc_encode($data, array('auto_dates'));
460         $v2 = php_xmlrpc_decode_xml($v1->serialize());
461         $this->assertEquals($v1, $v2);
462         $r1 = new PhpXmlRpc\Response($v1);
463         $r2 = php_xmlrpc_decode_xml($r1->serialize());
464         $r2->serialize(); // needed to set internal member payload
465         $this->assertEquals($r1, $r2);
466         $m1 = new PhpXmlRpc\Request('hello dolly', array($v1));
467         $m2 = php_xmlrpc_decode_xml($m1->serialize());
468         $m2->serialize(); // needed to set internal member payload
469         $this->assertEquals($m1, $m2);
470     }
471
472     public function testUTF8Request()
473     {
474         $sendstring = 'κόσμε'; // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
475         $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
476         \PhpXmlRpc\PhpXmlRpc::importGlobals();
477         $f = new xmlrpcval($sendstring, 'string');
478         $v = $f->serialize();
479         $this->assertEquals("<value><string>&#954;&#8057;&#963;&#956;&#949;</string></value>\n", $v);
480         $GLOBALS['xmlrpc_internalencoding'] = 'ISO-8859-1';
481         \PhpXmlRpc\PhpXmlRpc::importGlobals();
482     }
483
484     public function testUTF8Response()
485     {
486         $string = chr(224) . chr(252) . chr(232);
487
488         $s = $this->newMsg('dummy');
489         $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
490 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
491 ';
492         $r = $s->parseResponse($f, false, 'phpvals');
493         $v = $r->value();
494         $v = $v['content'];
495         $this->assertEquals($string, $v);
496
497         $f = '<?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
498 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
499 ';
500         $r = $s->parseResponse($f, false, 'phpvals');
501         $v = $r->value();
502         $v = $v['content'];
503         $this->assertEquals($string, $v);
504
505         $r = php_xmlrpc_decode_xml($f);
506         $v = $r->value();
507         $v = $v->structmem('content')->scalarval();
508         $this->assertEquals($string, $v);
509     }
510
511     public function testLatin1Response()
512     {
513         $string = chr(224) . chr(252) . chr(232);
514
515         $s = $this->newMsg('dummy');
516         $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
517 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
518 ';
519         $r = $s->parseResponse($f, false, 'phpvals');
520         $v = $r->value();
521         $v = $v['content'];
522         $this->assertEquals($string, $v);
523
524         $f = '<?xml version="1.0" encoding="ISO-8859-1"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
525 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
526 ';
527         $r = $s->parseResponse($f, false, 'phpvals');
528         $v = $r->value();
529         $v = $v['content'];
530         $this->assertEquals($string, $v);
531
532         $r = php_xmlrpc_decode_xml($f);
533         $v = $r->value();
534         $v = $v->structmem('content')->scalarval();
535         $this->assertEquals($string, $v);
536     }
537
538     public function testUTF8IntString()
539     {
540         $v = new xmlrpcval(100, 'int');
541         $s = $v->serialize('UTF-8');
542         $this->assertequals("<value><int>100</int></value>\n", $s);
543     }
544
545     public function testStringInt()
546     {
547         $v = new xmlrpcval('hello world', 'int');
548         $s = $v->serialize();
549         $this->assertequals("<value><int>0</int></value>\n", $s);
550     }
551
552     public function testStructMemExists()
553     {
554         $v = php_xmlrpc_encode(array('hello' => 'world'));
555         $b = $v->structmemexists('hello');
556         $this->assertequals(true, $b);
557         $b = $v->structmemexists('world');
558         $this->assertequals(false, $b);
559     }
560
561     public function testNilvalue()
562     {
563         // default case: we do not accept nil values received
564         $v = new xmlrpcval('hello', 'null');
565         $r = new xmlrpcresp($v);
566         $s = $r->serialize();
567         $m = $this->newMsg('dummy');
568         $r = $m->parseresponse($s);
569         $this->assertequals(2, $r->faultCode());
570         // enable reception of nil values
571         $GLOBALS['xmlrpc_null_extension'] = true;
572         \PhpXmlRpc\PhpXmlRpc::importGlobals();
573         $r = $m->parseresponse($s);
574         $v = $r->value();
575         $this->assertequals('null', $v->scalartyp());
576         // test with the apache version: EX:NIL
577         $GLOBALS['xmlrpc_null_apache_encoding'] = true;
578         \PhpXmlRpc\PhpXmlRpc::importGlobals();
579         // serialization
580         $v = new xmlrpcval('hello', 'null');
581         $s = $v->serialize();
582         $this->assertequals(1, preg_match('#<value><ex:nil/></value>#', $s));
583         // deserialization
584         $r = new xmlrpcresp($v);
585         $s = $r->serialize();
586         $r = $m->parseresponse($s);
587         $v = $r->value();
588         $this->assertequals('null', $v->scalartyp());
589         $GLOBALS['xmlrpc_null_extension'] = false;
590         \PhpXmlRpc\PhpXmlRpc::importGlobals();
591         $r = $m->parseresponse($s);
592         $this->assertequals(2, $r->faultCode());
593     }
594
595     public function testLocale()
596     {
597         $locale = setlocale(LC_NUMERIC, 0);
598         /// @todo on php 5.3/win setting locale to german does not seem to set decimal separator to comma...
599         if (setlocale(LC_NUMERIC, 'deu', 'de_DE@euro', 'de_DE', 'de', 'ge') !== false) {
600             $v = new xmlrpcval(1.1, 'double');
601             if (strpos($v->scalarval(), ',') == 1) {
602                 $r = $v->serialize();
603                 $this->assertequals(false, strpos($r, ','));
604                 setlocale(LC_NUMERIC, $locale);
605             } else {
606                 setlocale(LC_NUMERIC, $locale);
607                 $this->markTestSkipped('did not find a locale which sets decimal separator to comma');
608             }
609         } else {
610             $this->markTestSkipped('did not find a locale which sets decimal separator to comma');
611         }
612     }
613
614     public function testArrayAccess()
615     {
616         $v1 = new xmlrpcval(array(new xmlrpcval('one'), new xmlrpcval('two')), 'array');
617         $this->assertequals(1, count($v1));
618         $out = array('me' => array(), 'mytype' => 2, '_php_class' => null);
619         foreach($v1 as $key => $val)
620         {
621             $expected = each($out);
622             $this->assertequals($expected['key'], $key);
623             if (gettype($expected['value']) == 'array') {
624                 $this->assertequals('array', gettype($val));
625             } else {
626                 $this->assertequals($expected['value'], $val);
627             }
628         }
629
630         $v2 = new \PhpXmlRpc\Value(array(new \PhpXmlRpc\Value('one'), new \PhpXmlRpc\Value('two')), 'array');
631         $this->assertequals(2, count($v2));
632         $out = array(0 => 'object', 1 => 'object');
633         foreach($v2 as $key => $val)
634         {
635             $expected = each($out);
636             $this->assertequals($expected['key'], $key);
637             $this->assertequals($expected['value'], gettype($val));
638         }
639     }
640 }