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