X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=php%2Fphpxmlrpc%2Ftests%2F4ClientTest.php;fp=php%2Fphpxmlrpc%2Ftests%2F2InvalidHostTest.php;h=a2942b4c2b718a6dc8a7c3a7ef64f401be4a7624;hb=c379c0fff5edc592cc5d5d647c7fadb91317db87;hp=1c81b550cabe772ee821f722f4a5e00e08580d38;hpb=ae8b10f8363f7a1df02e77cbd820904c4ded10b8;p=plcapi.git diff --git a/php/phpxmlrpc/tests/2InvalidHostTest.php b/php/phpxmlrpc/tests/4ClientTest.php similarity index 76% rename from php/phpxmlrpc/tests/2InvalidHostTest.php rename to php/phpxmlrpc/tests/4ClientTest.php index 1c81b55..a2942b4 100644 --- a/php/phpxmlrpc/tests/2InvalidHostTest.php +++ b/php/phpxmlrpc/tests/4ClientTest.php @@ -4,34 +4,39 @@ include_once __DIR__ . '/../lib/xmlrpc.inc'; include_once __DIR__ . '/parse_args.php'; +include_once __DIR__ . '/PolyfillTestCase.php'; + +use PHPUnit\Runner\BaseTestRunner; + /** - * Tests involving requests sent to non-existing servers + * Tests involving the Client class. + * So far: only tests requests sent to non-existing servers */ -class InvalidHostTest extends PHPUnit_Framework_TestCase +class ClientTest extends PhpXmlRpc_PolyfillTestCase { /** @var xmlrpc_client $client */ public $client = null; public $args = array(); - public function setUp() + public function set_up() { $this->args = argParser::getArgs(); - $this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['LOCALSERVER'], 80); + $this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['HTTPSERVER'], 80); $this->client->setDebug($this->args['DEBUG']); if ($this->args['DEBUG'] == 1) ob_start(); } - protected function tearDown() + protected function tear_down() { if ($this->args['DEBUG'] != 1) return; $out = ob_get_clean(); $status = $this->getStatus(); - if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR - || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { + if ($status == BaseTestRunner::STATUS_ERROR + || $status == BaseTestRunner::STATUS_FAILURE) { echo $out; } } @@ -51,12 +56,12 @@ class InvalidHostTest extends PHPUnit_Framework_TestCase new xmlrpcval('hello', 'string'), )); $this->client->server .= 'XXX'; - $r = $this->client->send($m, 5); - // make sure there's no freaking catchall DNS in effect - $dnsinfo = dns_get_record($this->client->server); + $dnsinfo = @dns_get_record($this->client->server); if ($dnsinfo) { $this->markTestSkipped('Seems like there is a catchall DNS in effect: host ' . $this->client->server . ' found'); } else { + $r = $this->client->send($m, 5); + // make sure there's no freaking catchall DNS in effect $this->assertEquals(5, $r->faultCode()); } } @@ -79,12 +84,12 @@ class InvalidHostTest extends PHPUnit_Framework_TestCase $this->assertTrue($r->faultCode() === 8 || $r->faultCode() == 5); // now test a successful connection - $server = explode(':', $this->args['LOCALSERVER']); + $server = explode(':', $this->args['HTTPSERVER']); if (count($server) > 1) { $this->client->port = $server[1]; } $this->client->server = $server[0]; - $this->client->path = $this->args['URI']; + $this->client->path = $this->args['HTTPURI']; $r = $this->client->send($m, 5, 'http11'); $this->assertEquals(0, $r->faultCode());