3 include_once __DIR__ . '/../lib/xmlrpc.inc';
4 include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc';
6 include_once __DIR__ . '/parse_args.php';
8 include_once __DIR__ . '/3LocalhostTest.php';
11 * Tests which stress http features of the library.
12 * Each of these tests iterates over (almost) all of the 'localhost' tests
14 class LocalhostMultiTest extends LocalhostTest
17 * Returns all test methods from the base class, except the ones which failed already
19 * @todo reintroduce skipping of tests which failed when executed individually if test runs happen as separate processes
20 * @todo reintroduce skipping of tests within the loop
22 public function getSingleHttpTestMethods()
24 $unsafeMethods = array(
25 'testCatchExceptions', 'testUtf8Method', 'testServerComments',
26 'testExoticCharsetsRequests', 'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3',
30 foreach(get_class_methods('LocalhostTest') as $method)
32 if(strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))
34 if (!isset(self::$failed_tests[$method])) {
35 $methods[$method] = array($method);
44 * @dataProvider getSingleHttpTestMethods
45 * @param string $method
47 public function testDeflate($method)
49 if(!function_exists('gzdeflate'))
51 $this->markTestSkipped('Zlib missing: cannot test deflate functionality');
55 $this->client->accepted_compression = array('deflate');
56 $this->client->request_compression = 'deflate';
62 * @dataProvider getSingleHttpTestMethods
63 * @param string $method
65 public function testGzip($method)
67 if(!function_exists('gzdeflate'))
69 $this->markTestSkipped('Zlib missing: cannot test gzip functionality');
73 $this->client->accepted_compression = array('gzip');
74 $this->client->request_compression = 'gzip';
79 public function testKeepAlives()
81 if(!function_exists('curl_init'))
83 $this->markTestSkipped('CURL missing: cannot test http 1.1');
87 $this->method = 'http11';
88 $this->client->method = 'http11';
89 $this->client->keepalive = true;
91 // to successfully test keepalive, we have to reuse the same client for all tests, we can not recreate one on setup/teardown...
92 foreach ($this->getSingleHttpTestMethods() as $methods) {
93 $method = $methods[0];
99 * @dataProvider getSingleHttpTestMethods
100 * @param string $method
102 public function testProxy($method)
104 if ($this->args['PROXYSERVER'] == '')
106 $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy');
110 $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
116 * @dataProvider getSingleHttpTestMethods
117 * @param string $method
119 public function testHttp11($method)
121 if(!function_exists('curl_init'))
123 $this->markTestSkipped('CURL missing: cannot test http 1.1');
127 $this->method = 'http11'; // not an error the double assignment!
128 $this->client->method = 'http11';
129 $this->client->keepalive = false;
135 * @dataProvider getSingleHttpTestMethods
136 * @param string $method
138 public function testHttp10Curl($method)
140 if(!function_exists('curl_init'))
142 $this->markTestSkipped('CURL missing: cannot test http 1.1');
146 $this->method = 'http10'; // not an error the double assignment!
147 $this->client->method = 'http10';
148 $this->client->keepalive = false;
149 $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_ALWAYS);
155 * @dataProvider getSingleHttpTestMethods
156 * @param string $method
158 public function testHttp11Gzip($method)
160 if(!function_exists('curl_init'))
162 $this->markTestSkipped('CURL missing: cannot test http 1.1');
165 $this->method = 'http11'; // not an error the double assignment!
166 $this->client->method = 'http11';
167 $this->client->keepalive = false;
168 $this->client->accepted_compression = array('gzip');
169 $this->client->request_compression = 'gzip';
175 * @dataProvider getSingleHttpTestMethods
176 * @param string $method
178 public function testHttp11Deflate($method)
180 if(!function_exists('curl_init'))
182 $this->markTestSkipped('CURL missing: cannot test http 1.1');
185 $this->method = 'http11'; // not an error the double assignment!
186 $this->client->method = 'http11';
187 $this->client->keepalive = false;
188 $this->client->accepted_compression = array('deflate');
189 $this->client->request_compression = 'deflate';
195 * @dataProvider getSingleHttpTestMethods
196 * @param string $method
198 public function testHttp11Proxy($method)
200 if(!function_exists('curl_init'))
202 $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy');
205 else if ($this->args['PROXYSERVER'] == '')
207 $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. http 1.1');
211 $this->method = 'http11'; // not an error the double assignment!
212 $this->client->method = 'http11';
213 $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
214 $this->client->keepalive = false;
220 * @dataProvider getSingleHttpTestMethods
221 * @param string $method
223 public function testHttps($method)
225 if(!function_exists('curl_init'))
227 $this->markTestSkipped('CURL missing: cannot test https functionality');
230 else if ($this->args['HTTPSSERVER'] == '')
232 $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
236 $this->client->server = $this->args['HTTPSSERVER'];
237 $this->method = 'https';
238 $this->client->method = 'https';
239 $this->client->path = $this->args['HTTPSURI'];
240 $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
241 $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
242 $this->client->setSSLVersion($this->args['SSLVERSION']);
248 * @dataProvider getSingleHttpTestMethods
249 * @param string $method
251 public function testHttpsSocket($method)
253 if ($this->args['HTTPSSERVER'] == '')
255 $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https');
259 $this->client->server = $this->args['HTTPSSERVER'];
260 $this->method = 'https';
261 $this->client->method = 'https';
262 $this->client->path = $this->args['HTTPSURI'];
263 $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
264 $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
265 $this->client->setSSLVersion($this->args['SSLVERSION']);
266 $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_NEVER);
272 * @dataProvider getSingleHttpTestMethods
273 * @param string $method
275 public function testHttpsProxy($method)
277 if(!function_exists('curl_init'))
279 $this->markTestSkipped('CURL missing: cannot test https w. proxy');
282 else if ($this->args['PROXYSERVER'] == '')
284 $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. https');
287 else if ($this->args['HTTPSSERVER'] == '')
289 $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https w. proxy');
293 $this->client->server = $this->args['HTTPSSERVER'];
294 $this->method = 'https';
295 $this->client->method = 'https';
296 $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
297 $this->client->path = $this->args['HTTPSURI'];
298 $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
299 $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
300 $this->client->setSSLVersion($this->args['SSLVERSION']);
306 * @dataProvider getSingleHttpTestMethods
307 * @param string $method
309 public function testUTF8Responses($method)
311 $this->addQueryParams(array('RESPONSE_ENCODING' => 'UTF-8'));
317 * @dataProvider getSingleHttpTestMethods
318 * @param string $method
320 public function testUTF8Requests($method)
322 $this->client->request_charset_encoding = 'UTF-8';
328 * @dataProvider getSingleHttpTestMethods
329 * @param string $method
331 public function testISOResponses($method)
333 $this->addQueryParams(array('RESPONSE_ENCODING' => 'ISO-8859-1'));
339 * @dataProvider getSingleHttpTestMethods
340 * @param string $method
342 public function testISORequests($method)
344 $this->client->request_charset_encoding = 'ISO-8859-1';
350 * @dataProvider getSingleHttpTestMethods
351 * @param string $method
353 public function testBasicAuth($method)
355 $this->client->setCredentials('test', 'test');
356 $this->addQueryParams(array('FORCE_AUTH' => 'Basic'));
362 * @dataProvider getSingleHttpTestMethods
363 * @param string $method
365 public function testDigestAuth($method)
367 if (!function_exists('curl_init'))
369 $this->markTestSkipped('CURL missing: cannot test digest auth functionality');
373 $this->client->setCredentials('test', 'test', CURLAUTH_DIGEST);
374 $this->addQueryParams(array('FORCE_AUTH' => 'Digest'));
375 $this->method = 'http11';
376 $this->client->method = 'http11';