Improve the way test suite reports error messages at DEBUG=1
[plcapi.git] / tests / 3LocalhostTest.php
1 <?php
2
3 include_once __DIR__ . '/../lib/xmlrpc.inc';
4 include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc';
5
6 include_once __DIR__ . '/parse_args.php';
7
8 class LocalhostTest extends PHPUnit_Framework_TestCase
9 {
10     /** @var xmlrpc_client $client */
11     protected $client = null;
12     protected $method = 'http';
13     protected $timeout = 10;
14     protected $request_compression = null;
15     protected $accepted_compression = '';
16     protected $args = array();
17
18     protected static $failed_tests = array();
19
20     protected $testId;
21     /** @var boolean $collectCodeCoverageInformation */
22     protected $collectCodeCoverageInformation;
23     protected $coverageScriptUrl;
24
25     public static function fail($message = '')
26     {
27         // save in a static var that this particular test has failed
28         // (but only if not called from subclass objects / multitests)
29         if (function_exists('debug_backtrace') && strtolower(get_called_class()) == 'localhosttests') {
30             $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
31             for ($i = 0; $i < count($trace); $i++) {
32                 if (strpos($trace[$i]['function'], 'test') === 0) {
33                     self::$failed_tests[$trace[$i]['function']] = true;
34                     break;
35                 }
36             }
37         }
38
39         parent::fail($message);
40     }
41
42     /**
43      * Reimplemented to allow us to collect code coverage info from the target server.
44      * Code taken from PHPUnit_Extensions_Selenium2TestCase
45      *
46      * @param PHPUnit_Framework_TestResult $result
47      * @return PHPUnit_Framework_TestResult
48      * @throws Exception
49      */
50     public function run(PHPUnit_Framework_TestResult $result = NULL)
51     {
52         $this->testId = get_class($this) . '__' . $this->getName();
53
54         if ($result === NULL) {
55             $result = $this->createResult();
56         }
57
58         $this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation();
59
60         parent::run($result);
61
62         if ($this->collectCodeCoverageInformation) {
63             $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage(
64                 $this->coverageScriptUrl,
65                 $this->testId
66             );
67             $result->getCodeCoverage()->append(
68                 $coverage->get(), $this
69             );
70         }
71
72         // do not call this before to give the time to the Listeners to run
73         //$this->getStrategy()->endOfTest($this->session);
74
75         return $result;
76     }
77
78     public function setUp()
79     {
80         $this->args = argParser::getArgs();
81
82         $server = explode(':', $this->args['LOCALSERVER']);
83         if (count($server) > 1) {
84             $this->client = new xmlrpc_client($this->args['URI'], $server[0], $server[1]);
85         } else {
86             $this->client = new xmlrpc_client($this->args['URI'], $this->args['LOCALSERVER']);
87         }
88
89         $this->client->setDebug($this->args['DEBUG']);
90         $this->client->request_compression = $this->request_compression;
91         $this->client->accepted_compression = $this->accepted_compression;
92
93         $this->coverageScriptUrl = 'http://' . $this->args['LOCALSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['URI'] );
94
95         if ($this->args['DEBUG'] == 1)
96             ob_start();
97     }
98
99     protected function tearDown()
100     {
101         if ($this->args['DEBUG'] != 1)
102             return;
103         $out = ob_get_clean();
104         $status = $this->getStatus();
105         if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR
106             || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
107             echo $out;
108         }
109     }
110
111     protected function send($msg, $errrorcode = 0, $return_response = false)
112     {
113         if ($this->collectCodeCoverageInformation) {
114             $this->client->setCookie('PHPUNIT_SELENIUM_TEST_ID', $this->testId);
115         }
116
117         $r = $this->client->send($msg, $this->timeout, $this->method);
118         // for multicall, return directly array of responses
119         if (is_array($r)) {
120             return $r;
121         }
122         if (is_array($errrorcode)) {
123             $this->assertContains($r->faultCode(), $errrorcode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
124         } else {
125             $this->assertEquals($r->faultCode(), $errrorcode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
126         }
127         if (!$r->faultCode()) {
128             if ($return_response) {
129                 return $r;
130             } else {
131                 return $r->value();
132             }
133         } else {
134             return;
135         }
136     }
137
138     public function testString()
139     {
140         $sendstring = "here are 3 \"entities\": < > & " .
141             "and here's a dollar sign: \$pretendvarname and a backslash too: " . chr(92) .
142             " - isn't that great? \\\"hackery\\\" at it's best " .
143             " also don't want to miss out on \$item[0]. " .
144             "The real weird stuff follows: CRLF here" . chr(13) . chr(10) .
145             "a simple CR here" . chr(13) .
146             "a simple LF here" . chr(10) .
147             "and then LFCR" . chr(10) . chr(13) .
148             "last but not least weird names: G" . chr(252) . "nter, El" . chr(232) . "ne, and an xml comment closing tag: -->";
149         $f = new xmlrpcmsg('examples.stringecho', array(
150             new xmlrpcval($sendstring, 'string'),
151         ));
152         $v = $this->send($f);
153         if ($v) {
154             // when sending/receiving non-US-ASCII encoded strings, XML says cr-lf can be normalized.
155             // so we relax our tests...
156             $l1 = strlen($sendstring);
157             $l2 = strlen($v->scalarval());
158             if ($l1 == $l2) {
159                 $this->assertEquals($sendstring, $v->scalarval());
160             } else {
161                 $this->assertEquals(str_replace(array("\r\n", "\r"), array("\n", "\n"), $sendstring), $v->scalarval());
162             }
163         }
164     }
165
166     public function testLatin1String()
167     {
168         $sendstring =
169             "last but not least weird names: G" . chr(252) . "nter, El" . chr(232) . "ne";
170         $f = '<?xml version="1.0" encoding="iso-8859-1"?><methodCall><methodName>examples.stringecho</methodName><params><param><value>'.
171             $sendstring.
172             '</value></param></params></methodCall>';
173         $v = $this->send($f);
174         if ($v) {
175             $this->assertEquals($sendstring, $v->scalarval());
176         }
177     }
178
179     public function testAddingDoubles()
180     {
181         // note that rounding errors mean we
182         // keep precision to sensible levels here ;-)
183         $a = 12.13;
184         $b = -23.98;
185         $f = new xmlrpcmsg('examples.addtwodouble', array(
186             new xmlrpcval($a, 'double'),
187             new xmlrpcval($b, 'double'),
188         ));
189         $v = $this->send($f);
190         if ($v) {
191             $this->assertEquals($a + $b, $v->scalarval());
192         }
193     }
194
195     public function testAdding()
196     {
197         $f = new xmlrpcmsg('examples.addtwo', array(
198             new xmlrpcval(12, 'int'),
199             new xmlrpcval(-23, 'int'),
200         ));
201         $v = $this->send($f);
202         if ($v) {
203             $this->assertEquals(12 - 23, $v->scalarval());
204         }
205     }
206
207     public function testInvalidNumber()
208     {
209         $f = new xmlrpcmsg('examples.addtwo', array(
210             new xmlrpcval('fred', 'int'),
211             new xmlrpcval("\"; exec('ls')", 'int'),
212         ));
213         $v = $this->send($f);
214         /// @todo a fault condition should be generated here
215         /// by the server, which we pick up on
216         if ($v) {
217             $this->assertEquals(0, $v->scalarval());
218         }
219     }
220
221     public function testBoolean()
222     {
223         $f = new xmlrpcmsg('examples.invertBooleans', array(
224             new xmlrpcval(array(
225                 new xmlrpcval(true, 'boolean'),
226                 new xmlrpcval(false, 'boolean'),
227                 new xmlrpcval(1, 'boolean'),
228                 new xmlrpcval(0, 'boolean'),
229                 //new xmlrpcval('true', 'boolean'),
230                 //new xmlrpcval('false', 'boolean')
231             ),
232                 'array'
233             ),));
234         $answer = '0101';
235         $v = $this->send($f);
236         if ($v) {
237             $sz = $v->arraysize();
238             $got = '';
239             for ($i = 0; $i < $sz; $i++) {
240                 $b = $v->arraymem($i);
241                 if ($b->scalarval()) {
242                     $got .= '1';
243                 } else {
244                     $got .= '0';
245                 }
246             }
247             $this->assertEquals($answer, $got);
248         }
249     }
250
251     public function testBase64()
252     {
253         $sendstring = 'Mary had a little lamb,
254 Whose fleece was white as snow,
255 And everywhere that Mary went
256 the lamb was sure to go.
257
258 Mary had a little lamb
259 She tied it to a pylon
260 Ten thousand volts went down its back
261 And turned it into nylon';
262         $f = new xmlrpcmsg('examples.decode64', array(
263             new xmlrpcval($sendstring, 'base64'),
264         ));
265         $v = $this->send($f);
266         if ($v) {
267             if (strlen($sendstring) == strlen($v->scalarval())) {
268                 $this->assertEquals($sendstring, $v->scalarval());
269             } else {
270                 $this->assertEquals(str_replace(array("\r\n", "\r"), array("\n", "\n"), $sendstring), $v->scalarval());
271             }
272         }
273     }
274
275     public function testDateTime()
276     {
277         $time = time();
278         $t1 = new xmlrpcval($time, 'dateTime.iso8601');
279         $t2 = new xmlrpcval(iso8601_encode($time), 'dateTime.iso8601');
280         $this->assertEquals($t1->serialize(), $t2->serialize());
281         if (class_exists('DateTime')) {
282             $datetime = new DateTime();
283             // skip this test for php 5.2. It is a bit harder there to build a DateTime from unix timestamp with proper TZ info
284             if (is_callable(array($datetime, 'setTimestamp'))) {
285                 $t3 = new xmlrpcval($datetime->setTimestamp($time), 'dateTime.iso8601');
286                 $this->assertEquals($t1->serialize(), $t3->serialize());
287             }
288         }
289     }
290
291     public function testCountEntities()
292     {
293         $sendstring = "h'fd>onc>>l>>rw&bpu>q>e<v&gxs<ytjzkami<";
294         $f = new xmlrpcmsg('validator1.countTheEntities', array(
295             new xmlrpcval($sendstring, 'string'),
296         ));
297         $v = $this->send($f);
298         if ($v) {
299             $got = '';
300             $expected = '37210';
301             $expect_array = array('ctLeftAngleBrackets', 'ctRightAngleBrackets', 'ctAmpersands', 'ctApostrophes', 'ctQuotes');
302             while (list(, $val) = each($expect_array)) {
303                 $b = $v->structmem($val);
304                 $got .= $b->me['int'];
305             }
306             $this->assertEquals($expected, $got);
307         }
308     }
309
310     public function _multicall_msg($method, $params)
311     {
312         $struct['methodName'] = new xmlrpcval($method, 'string');
313         $struct['params'] = new xmlrpcval($params, 'array');
314
315         return new xmlrpcval($struct, 'struct');
316     }
317
318     public function testServerMulticall()
319     {
320         // We manually construct a system.multicall() call to ensure
321         // that the server supports it.
322
323         // NB: This test will NOT pass if server does not support system.multicall.
324
325         // Based on http://xmlrpc-c.sourceforge.net/hacks/test_multicall.py
326         $good1 = $this->_multicall_msg(
327             'system.methodHelp',
328             array(php_xmlrpc_encode('system.listMethods')));
329         $bad = $this->_multicall_msg(
330             'test.nosuch',
331             array(php_xmlrpc_encode(1), php_xmlrpc_encode(2)));
332         $recursive = $this->_multicall_msg(
333             'system.multicall',
334             array(new xmlrpcval(array(), 'array')));
335         $good2 = $this->_multicall_msg(
336             'system.methodSignature',
337             array(php_xmlrpc_encode('system.listMethods')));
338         $arg = new xmlrpcval(
339             array($good1, $bad, $recursive, $good2),
340             'array'
341         );
342
343         $f = new xmlrpcmsg('system.multicall', array($arg));
344         $v = $this->send($f);
345         if ($v) {
346             //$this->assertTrue($r->faultCode() == 0, "fault from system.multicall");
347             $this->assertTrue($v->arraysize() == 4, "bad number of return values");
348
349             $r1 = $v->arraymem(0);
350             $this->assertTrue(
351                 $r1->kindOf() == 'array' && $r1->arraysize() == 1,
352                 "did not get array of size 1 from good1"
353             );
354
355             $r2 = $v->arraymem(1);
356             $this->assertTrue(
357                 $r2->kindOf() == 'struct',
358                 "no fault from bad"
359             );
360
361             $r3 = $v->arraymem(2);
362             $this->assertTrue(
363                 $r3->kindOf() == 'struct',
364                 "recursive system.multicall did not fail"
365             );
366
367             $r4 = $v->arraymem(3);
368             $this->assertTrue(
369                 $r4->kindOf() == 'array' && $r4->arraysize() == 1,
370                 "did not get array of size 1 from good2"
371             );
372         }
373     }
374
375     public function testClientMulticall1()
376     {
377         // NB: This test will NOT pass if server does not support system.multicall.
378
379         $this->client->no_multicall = false;
380
381         $good1 = new xmlrpcmsg('system.methodHelp',
382             array(php_xmlrpc_encode('system.listMethods')));
383         $bad = new xmlrpcmsg('test.nosuch',
384             array(php_xmlrpc_encode(1), php_xmlrpc_encode(2)));
385         $recursive = new xmlrpcmsg('system.multicall',
386             array(new xmlrpcval(array(), 'array')));
387         $good2 = new xmlrpcmsg('system.methodSignature',
388             array(php_xmlrpc_encode('system.listMethods'))
389         );
390
391         $r = $this->send(array($good1, $bad, $recursive, $good2));
392         if ($r) {
393             $this->assertTrue(count($r) == 4, "wrong number of return values");
394         }
395
396         $this->assertTrue($r[0]->faultCode() == 0, "fault from good1");
397         if (!$r[0]->faultCode()) {
398             $val = $r[0]->value();
399             $this->assertTrue(
400                 $val->kindOf() == 'scalar' && $val->scalartyp() == 'string',
401                 "good1 did not return string"
402             );
403         }
404         $this->assertTrue($r[1]->faultCode() != 0, "no fault from bad");
405         $this->assertTrue($r[2]->faultCode() != 0, "no fault from recursive system.multicall");
406         $this->assertTrue($r[3]->faultCode() == 0, "fault from good2");
407         if (!$r[3]->faultCode()) {
408             $val = $r[3]->value();
409             $this->assertTrue($val->kindOf() == 'array', "good2 did not return array");
410         }
411         // This is the only assert in this test which should fail
412         // if the test server does not support system.multicall.
413         $this->assertTrue($this->client->no_multicall == false,
414             "server does not support system.multicall"
415         );
416     }
417
418     public function testClientMulticall2()
419     {
420         // NB: This test will NOT pass if server does not support system.multicall.
421
422         $this->client->no_multicall = true;
423
424         $good1 = new xmlrpcmsg('system.methodHelp',
425             array(php_xmlrpc_encode('system.listMethods')));
426         $bad = new xmlrpcmsg('test.nosuch',
427             array(php_xmlrpc_encode(1), php_xmlrpc_encode(2)));
428         $recursive = new xmlrpcmsg('system.multicall',
429             array(new xmlrpcval(array(), 'array')));
430         $good2 = new xmlrpcmsg('system.methodSignature',
431             array(php_xmlrpc_encode('system.listMethods'))
432         );
433
434         $r = $this->send(array($good1, $bad, $recursive, $good2));
435         if ($r) {
436             $this->assertTrue(count($r) == 4, "wrong number of return values");
437         }
438
439         $this->assertTrue($r[0]->faultCode() == 0, "fault from good1");
440         if (!$r[0]->faultCode()) {
441             $val = $r[0]->value();
442             $this->assertTrue(
443                 $val->kindOf() == 'scalar' && $val->scalartyp() == 'string',
444                 "good1 did not return string");
445         }
446         $this->assertTrue($r[1]->faultCode() != 0, "no fault from bad");
447         $this->assertTrue($r[2]->faultCode() == 0, "fault from (non recursive) system.multicall");
448         $this->assertTrue($r[3]->faultCode() == 0, "fault from good2");
449         if (!$r[3]->faultCode()) {
450             $val = $r[3]->value();
451             $this->assertTrue($val->kindOf() == 'array', "good2 did not return array");
452         }
453     }
454
455     public function testClientMulticall3()
456     {
457         // NB: This test will NOT pass if server does not support system.multicall.
458
459         $this->client->return_type = 'phpvals';
460         $this->client->no_multicall = false;
461
462         $good1 = new xmlrpcmsg('system.methodHelp',
463             array(php_xmlrpc_encode('system.listMethods')));
464         $bad = new xmlrpcmsg('test.nosuch',
465             array(php_xmlrpc_encode(1), php_xmlrpc_encode(2)));
466         $recursive = new xmlrpcmsg('system.multicall',
467             array(new xmlrpcval(array(), 'array')));
468         $good2 = new xmlrpcmsg('system.methodSignature',
469             array(php_xmlrpc_encode('system.listMethods'))
470         );
471
472         $r = $this->send(array($good1, $bad, $recursive, $good2));
473         if ($r) {
474             $this->assertTrue(count($r) == 4, "wrong number of return values");
475         }
476         $this->assertTrue($r[0]->faultCode() == 0, "fault from good1");
477         if (!$r[0]->faultCode()) {
478             $val = $r[0]->value();
479             $this->assertTrue(
480                 is_string($val), "good1 did not return string");
481         }
482         $this->assertTrue($r[1]->faultCode() != 0, "no fault from bad");
483         $this->assertTrue($r[2]->faultCode() != 0, "no fault from recursive system.multicall");
484         $this->assertTrue($r[3]->faultCode() == 0, "fault from good2");
485         if (!$r[3]->faultCode()) {
486             $val = $r[3]->value();
487             $this->assertTrue(is_array($val), "good2 did not return array");
488         }
489         $this->client->return_type = 'xmlrpcvals';
490     }
491
492     public function testCatchWarnings()
493     {
494         $f = new xmlrpcmsg('examples.generatePHPWarning', array(
495             new xmlrpcval('whatever', 'string'),
496         ));
497         $v = $this->send($f);
498         if ($v) {
499             $this->assertEquals($v->scalarval(), true);
500         }
501     }
502
503     public function testCatchExceptions()
504     {
505         $f = new xmlrpcmsg('examples.raiseException', array(
506             new xmlrpcval('whatever', 'string'),
507         ));
508         $v = $this->send($f, $GLOBALS['xmlrpcerr']['server_error']);
509         $this->client->path = $this->args['URI'] . '?EXCEPTION_HANDLING=1';
510         $v = $this->send($f, 1);
511         $this->client->path = $this->args['URI'] . '?EXCEPTION_HANDLING=2';
512         // depending on whether display_errors is ON or OFF on the server, we will get back a different error here,
513         // as php will generate an http status code of either 200 or 500...
514         $v = $this->send($f, array($GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcerr']['http_error']));
515     }
516
517     public function testZeroParams()
518     {
519         $f = new xmlrpcmsg('system.listMethods');
520         $v = $this->send($f);
521     }
522
523     public function testCodeInjectionServerSide()
524     {
525         $f = new xmlrpcmsg('system.MethodHelp');
526         $f->payload = "<?xml version=\"1.0\"?><methodCall><methodName>validator1.echoStructTest</methodName><params><param><value><struct><member><name>','')); echo('gotcha!'); die(); //</name></member></struct></value></param></params></methodCall>";
527         $v = $this->send($f);
528         //$v = $r->faultCode();
529         if ($v) {
530             $this->assertEquals(0, $v->structsize());
531         }
532     }
533
534     public function testAutoRegisteredFunction()
535     {
536         $f = new xmlrpcmsg('examples.php.getStateName', array(
537             new xmlrpcval(23, 'int'),
538         ));
539         $v = $this->send($f);
540         if ($v) {
541             $this->assertEquals('Michigan', $v->scalarval());
542         } else {
543             $this->fail('Note: server can only auto register functions if running with PHP 5.0.3 and up');
544         }
545     }
546
547     public function testAutoRegisteredClass()
548     {
549         $f = new xmlrpcmsg('examples.php2.getStateName', array(
550             new xmlrpcval(23, 'int'),
551         ));
552         $v = $this->send($f);
553         if ($v) {
554             $this->assertEquals('Michigan', $v->scalarval());
555             $f = new xmlrpcmsg('examples.php3.getStateName', array(
556                 new xmlrpcval(23, 'int'),
557             ));
558             $v = $this->send($f);
559             if ($v) {
560                 $this->assertEquals('Michigan', $v->scalarval());
561             }
562         } else {
563             $this->fail('Note: server can only auto register class methods if running with PHP 5.0.3 and up');
564         }
565     }
566
567     public function testAutoRegisteredMethod()
568     {
569         // make a 'deep client copy' as the original one might have many properties set
570         $func = wrap_xmlrpc_method($this->client, 'examples.getStateName', array('simple_client_copy' => 1));
571         if ($func == '') {
572             $this->fail('Registration of examples.getStateName failed');
573         } else {
574             $v = $func(23);
575             // work around bug in current version of phpunit
576             if (is_object($v)) {
577                 $v = var_export($v, true);
578             }
579             $this->assertEquals('Michigan', $v);
580         }
581     }
582
583     public function testGetCookies()
584     {
585         // let server set to us some cookies we tell it
586         $cookies = array(
587             //'c1' => array(),
588             'c2' => array('value' => 'c2'),
589             'c3' => array('value' => 'c3', 'expires' => time() + 60 * 60 * 24 * 30),
590             'c4' => array('value' => 'c4', 'expires' => time() + 60 * 60 * 24 * 30, 'path' => '/'),
591             'c5' => array('value' => 'c5', 'expires' => time() + 60 * 60 * 24 * 30, 'path' => '/', 'domain' => 'localhost'),
592         );
593         $cookiesval = php_xmlrpc_encode($cookies);
594         $f = new xmlrpcmsg('examples.setcookies', array($cookiesval));
595         $r = $this->send($f, 0, true);
596         if ($r) {
597             $v = $r->value();
598             $this->assertEquals(1, $v->scalarval());
599             // now check if we decoded the cookies as we had set them
600             $rcookies = $r->cookies();
601             // remove extra cookies which might have been set by proxies
602             foreach ($rcookies as $c => $v) {
603                 if (!in_array($c, array('c2', 'c3', 'c4', 'c5'))) {
604                     unset($rcookies[$c]);
605                 }
606                 // Seems like we get this when using php-fpm and php 5.5+ ...
607                 if (isset($rcookies[$c]['Max-Age'])) {
608                     unset($rcookies[$c]['Max-Age']);
609                 }
610             }
611             foreach ($cookies as $c => $v) {
612                 // format for date string in cookies: 'Mon, 31 Oct 2005 13:50:56 GMT'
613                 // but PHP versions differ on that, some use 'Mon, 31-Oct-2005 13:50:56 GMT'...
614                 if (isset($v['expires'])) {
615                     if (isset($rcookies[$c]['expires']) && strpos($rcookies[$c]['expires'], '-')) {
616                         $cookies[$c]['expires'] = gmdate('D, d\-M\-Y H:i:s \G\M\T', $cookies[$c]['expires']);
617                     } else {
618                         $cookies[$c]['expires'] = gmdate('D, d M Y H:i:s \G\M\T', $cookies[$c]['expires']);
619                     }
620                 }
621             }
622
623             $this->assertEquals($cookies, $rcookies);
624         }
625     }
626
627     public function testSetCookies()
628     {
629         // let server set to us some cookies we tell it
630         $cookies = array(
631             'c0' => null,
632             'c1' => 1,
633             'c2' => '2 3',
634             'c3' => '!@#$%^&*()_+|}{":?><,./\';[]\\=-',
635         );
636         $f = new xmlrpcmsg('examples.getcookies', array());
637         foreach ($cookies as $cookie => $val) {
638             $this->client->setCookie($cookie, $val);
639             $cookies[$cookie] = (string)$cookies[$cookie];
640         }
641         $r = $this->client->send($f, $this->timeout, $this->method);
642         $this->assertEquals($r->faultCode(), 0, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
643         if (!$r->faultCode()) {
644             $v = $r->value();
645             $v = php_xmlrpc_decode($v);
646
647             // take care for the extra cookie used for coverage collection
648             if (isset($v['PHPUNIT_SELENIUM_TEST_ID'])) {
649                 unset($v['PHPUNIT_SELENIUM_TEST_ID']);
650             }
651
652             // on IIS and Apache getallheaders returns something slightly different...
653             $this->assertEquals($v, $cookies);
654         }
655     }
656
657     public function testSendTwiceSameMsg()
658     {
659         $f = new xmlrpcmsg('examples.stringecho', array(
660             new xmlrpcval('hello world', 'string'),
661         ));
662         $v1 = $this->send($f);
663         $v2 = $this->send($f);
664         //$v = $r->faultCode();
665         if ($v1 && $v2) {
666             $this->assertEquals($v2, $v1);
667         }
668     }
669 }