3 include_once(__DIR__.'/../lib/xmlrpc.inc');
5 include_once(__DIR__.'/parse_args.php');
7 class InvalidHostTest extends PHPUnit_Framework_TestCase
14 $this->args = argParser::getArgs();
16 $this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['LOCALSERVER'], 80);
17 if($this->args['DEBUG'])
19 $this->client->setDebug($this->args['DEBUG']);
25 $f = new xmlrpcmsg('examples.echo',array(
26 new xmlrpcval('hello', 'string')
28 $r = $this->client->send($f, 5);
29 $this->assertEquals(5, $r->faultCode());
32 function testSrvNotFound()
34 $f = new xmlrpcmsg('examples.echo',array(
35 new xmlrpcval('hello', 'string')
37 $this->client->server .= 'XXX';
38 $r = $this->client->send($f, 5);
39 // make sure there's no freaking catchall DNS in effect
40 $dnsinfo = dns_get_record($this->client->server);
43 $this->markTestSkipped('Seems like there is a catchall DNS in effect: host ' . $this->client->server . ' found');
47 $this->assertEquals(5, $r->faultCode());
51 function testCurlKAErr()
53 if(!function_exists('curl_init'))
55 $this->markTestSkipped('CURL missing: cannot test curl keepalive errors');
58 $f = new xmlrpcmsg('examples.stringecho',array(
59 new xmlrpcval('hello', 'string')
61 // test 2 calls w. keepalive: 1st time connection ko, second time ok
62 $this->client->server .= 'XXX';
63 $this->client->keepalive = true;
64 $r = $this->client->send($f, 5, 'http11');
65 // in case we have a "universal dns resolver" getting in the way, we might get a 302 instead of a 404
66 $this->assertTrue($r->faultCode() === 8 || $r->faultCode() == 5);
68 // now test a successful connection
69 $server = explode(':', $this->args['LOCALSERVER']);
70 if(count($server) > 1)
72 $this->client->port = $server[1];
74 $this->client->server = $server[0];
75 $this->client->path = $this->args['URI'];
77 $r = $this->client->send($f, 5, 'http11');
78 $this->assertEquals(0, $r->faultCode());
80 is_object( $ro ) && $this->assertEquals('hello', $ro->scalarVal());