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