{
parent::set_up();
- $this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['HTTPSERVER'], 80);
- $this->client->setDebug($this->args['DEBUG']);
+ $this->client = $this->getClient();
}
public function test404()
{
+ $this->client->path = '/NOTEXIST.php';
+
$m = new xmlrpcmsg('examples.echo', array(
new xmlrpcval('hello', 'string'),
));
public function test404Interop()
{
+ $this->client->path = '/NOTEXIST.php';
+
$m = new xmlrpcmsg('examples.echo', array(
new xmlrpcval('hello', 'string'),
));
public function testSrvNotFound()
{
- $m = new xmlrpcmsg('examples.echo', array(
- new xmlrpcval('hello', 'string'),
- ));
$this->client->server .= 'XXX';
$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 {
+ $m = new xmlrpcmsg('examples.echo', array(
+ new xmlrpcval('hello', 'string'),
+ ));
$r = $this->client->send($m, 5);
// make sure there's no freaking catchall DNS in effect
$this->assertEquals(5, $r->faultCode());
$this->client->port = $server[1];
}
$this->client->server = $server[0];
- $this->client->path = $this->args['HTTPURI'];
- $this->client->setCookie('PHPUNIT_RANDOM_TEST_ID', static::$randId);
+ //$this->client->path = $this->args['HTTPURI'];
+ //$this->client->setCookie('PHPUNIT_RANDOM_TEST_ID', static::$randId);
$r = $this->client->send($m, 5, 'http11');
$this->assertEquals(0, $r->faultCode());
$ro = $r->value();
is_object($ro) && $this->assertEquals('hello', $ro->scalarVal());
}
- public function testCustomHeaders()
+ /**
+ * @dataProvider getAvailableUseCurlOptions
+ */
+ public function testCustomHeaders($curlOpt)
+ {
+ $this->client->setOption(\PhpXmlRpc\Client::OPT_USE_CURL, $curlOpt);
+ $this->client->setOption(\PhpXmlRpc\Client::OPT_EXTRA_HEADERS, array('X-PXR-Test: yes'));
+ $r = new \PhpXmlRpc\Request('tests.getallheaders');
+ $r = $this->client->send($r);
+ $this->assertEquals(0, $r->faultCode());
+ $ro = $r->value();
+ $this->assertArrayHasKey('X-Pxr-Test', $ro->scalarVal(), "Testing with curl mode: $curlOpt");
+ }
+
+ public function getAvailableUseCurlOptions()
{
$opts = array(\PhpXmlRpc\Client::USE_CURL_NEVER);
if (function_exists('curl_init'))
$opts[] = \PhpXmlRpc\Client::USE_CURL_ALWAYS;
}
- $this->client->setOption(\PhpXmlRpc\Client::OPT_EXTRA_HEADERS, array('X-PXR-Test: yes'));
- $r = new \PhpXmlRpc\Request('tests.getallheaders');
-
- foreach ($opts as $opt) {
- $this->client->setOption(\PhpXmlRpc\Client::OPT_USE_CURL, $opt);
- $r = $this->client->send($r);
- $this->assertEquals(0, $r->faultCode());
- $ro = $r->value();
- $this->assertArrayHasKey('X-Pxr-Test', $ro->scalarVal(), "Testing with curl mode: $opt");
- }
+ return array($opts);
}
public function testgetUrl()
{
parent::set_up();
- $server = explode(':', $this->args['HTTPSERVER']);
- if (count($server) > 1) {
- $this->client = new xmlrpc_client($this->args['HTTPURI'], $server[0], $server[1]);
- } else {
- $this->client = new xmlrpc_client($this->args['HTTPURI'], $this->args['HTTPSERVER']);
- }
+ $this->client = $this->getClient();
- $this->client->setDebug($this->args['DEBUG']);
$this->client->request_compression = $this->request_compression;
$this->client->accepted_compression = $this->accepted_compression;
-
- $this->client->setCookie('PHPUNIT_RANDOM_TEST_ID', static::$randId);
-
- if ($this->collectCodeCoverageInformation) {
- $this->client->setCookie('PHPUNIT_SELENIUM_TEST_ID', $this->testId);
- }
}
/**
$this->baseUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|\?.+|', '', $this->args['HTTPURI']);
$this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
}
+
+ protected function getClient($customPath)
+ {
+ $server = explode(':', $this->args['HTTPSERVER']);
+ if (count($server) > 1) {
+ $client = new xmlrpc_client($this->args['HTTPURI'], $server[0], $server[1]);
+ } else {
+ $client = new xmlrpc_client($this->args['HTTPURI'], $this->args['HTTPSERVER']);
+ }
+
+ $client->setDebug($this->args['DEBUG']);
+
+ $client->setCookie('PHPUNIT_RANDOM_TEST_ID', static::$randId);
+
+ if ($this->collectCodeCoverageInformation) {
+ $client->setCookie('PHPUNIT_SELENIUM_TEST_ID', $this->testId);
+ }
+
+ return $client;
+ }
}