X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2F4LocalhostMultiTest.php;h=619e3ae1dad1108dda3d49daf2952c02adbb63e1;hb=8ccaf4d728232a7537ab964885c526175cb20e09;hp=e5d365a0738bebbba73c1745ea55107535f78f47;hpb=75234d12e752f022fcf8e5994a0dd8783dec54ab;p=plcapi.git diff --git a/tests/4LocalhostMultiTest.php b/tests/4LocalhostMultiTest.php index e5d365a..619e3ae 100644 --- a/tests/4LocalhostMultiTest.php +++ b/tests/4LocalhostMultiTest.php @@ -14,89 +14,148 @@ include_once __DIR__ . '/3LocalhostTest.php'; class LocalhostMultiTest extends LocalhostTest { /** - * @todo reintroduce skipping of tests which failed when executed individually if test runs happen as separate processes + * Returns all test methods from the base class, except the ones which failed already + * + * @todo (re)introduce skipping of tests which failed when executed individually even if test runs happen as separate processes * @todo reintroduce skipping of tests within the loop */ - function _runtests() + public function getSingleHttpTestMethods() { - $unsafeMethods = array('testHttps', 'testCatchExceptions', 'testUtf8Method', 'testServerComments', 'testExoticCharsetsRequests', 'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3'); + $unsafeMethods = array( + 'testCatchExceptions', 'testUtf8Method', 'testServerComments', + 'testExoticCharsetsRequests', 'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3', + ); + + $methods = array(); foreach(get_class_methods('LocalhostTest') as $method) { if(strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods)) { - if (!isset(self::$failed_tests[$method])) - $this->$method(); + if (!isset(self::$failed_tests[$method])) { + $methods[$method] = array($method); + } } - /*if ($this->_failed) - { - break; - }*/ } + + return $methods; } - function testDeflate() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testDeflate($method) { if(!function_exists('gzdeflate')) { $this->markTestSkipped('Zlib missing: cannot test deflate functionality'); return; } + $this->client->accepted_compression = array('deflate'); $this->client->request_compression = 'deflate'; - $this->_runtests(); + + $this->$method(); } - function testGzip() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testGzip($method) { if(!function_exists('gzdeflate')) { $this->markTestSkipped('Zlib missing: cannot test gzip functionality'); return; } + $this->client->accepted_compression = array('gzip'); $this->client->request_compression = 'gzip'; - $this->_runtests(); + + $this->$method(); } - function testKeepAlives() + public function testKeepAlives() { if(!function_exists('curl_init')) { $this->markTestSkipped('CURL missing: cannot test http 1.1'); return; } + $this->method = 'http11'; + $this->client->method = 'http11'; $this->client->keepalive = true; - $this->_runtests(); + + // to successfully test keepalive, we have to reuse the same client for all tests, we can not recreate one on setup/teardown... + foreach ($this->getSingleHttpTestMethods() as $methods) { + $method = $methods[0]; + $this->$method(); + } } - function testProxy() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testProxy($method) { - if ($this->args['PROXYSERVER']) + if ($this->args['PROXYSERVER'] == '') { - $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']); - $this->_runtests(); + $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy'); + return; } - else - $this->markTestSkipped('PROXY definition missing: cannot test proxy'); + + $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']); + + $this->$method(); } - function testHttp11() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttp11($method) { if(!function_exists('curl_init')) { $this->markTestSkipped('CURL missing: cannot test http 1.1'); return; } + $this->method = 'http11'; // not an error the double assignment! $this->client->method = 'http11'; - //$this->client->verifyhost = 0; - //$this->client->verifypeer = 0; $this->client->keepalive = false; - $this->_runtests(); + + $this->$method(); } - function testHttp11Gzip() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttp10Curl($method) + { + if(!function_exists('curl_init')) + { + $this->markTestSkipped('CURL missing: cannot test http 1.1'); + return; + } + + $this->method = 'http10'; // not an error the double assignment! + $this->client->method = 'http10'; + $this->client->keepalive = false; + $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_ALWAYS); + + $this->$method(); + } + + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttp11Gzip($method) { if(!function_exists('curl_init')) { @@ -108,10 +167,15 @@ class LocalhostMultiTest extends LocalhostTest $this->client->keepalive = false; $this->client->accepted_compression = array('gzip'); $this->client->request_compression = 'gzip'; - $this->_runtests(); + + $this->$method(); } - function testHttp11Deflate() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttp11Deflate($method) { if(!function_exists('curl_init')) { @@ -123,10 +187,15 @@ class LocalhostMultiTest extends LocalhostTest $this->client->keepalive = false; $this->client->accepted_compression = array('deflate'); $this->client->request_compression = 'deflate'; - $this->_runtests(); + + $this->$method(); } - function testHttp11Proxy() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttp11Proxy($method) { if(!function_exists('curl_init')) { @@ -135,25 +204,58 @@ class LocalhostMultiTest extends LocalhostTest } else if ($this->args['PROXYSERVER'] == '') { - $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1'); + $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. http 1.1'); return; } + $this->method = 'http11'; // not an error the double assignment! $this->client->method = 'http11'; $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']); - //$this->client->verifyhost = 0; - //$this->client->verifypeer = 0; $this->client->keepalive = false; - $this->_runtests(); + + $this->$method(); } - function testHttps() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttps($method) { if(!function_exists('curl_init')) { $this->markTestSkipped('CURL missing: cannot test https functionality'); return; } + else if ($this->args['HTTPSSERVER'] == '') + { + $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https'); + return; + } + + $this->client->server = $this->args['HTTPSSERVER']; + $this->method = 'https'; + $this->client->method = 'https'; + $this->client->path = $this->args['HTTPSURI']; + $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']); + $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']); + $this->client->setSSLVersion($this->args['SSLVERSION']); + + $this->$method(); + } + + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttpsSocket($method) + { + if ($this->args['HTTPSSERVER'] == '') + { + $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https'); + return; + } + $this->client->server = $this->args['HTTPSSERVER']; $this->method = 'https'; $this->client->method = 'https'; @@ -161,21 +263,33 @@ class LocalhostMultiTest extends LocalhostTest $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']); $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']); $this->client->setSSLVersion($this->args['SSLVERSION']); - $this->_runtests(); + $this->client->setUseCurl(\PhpXmlRpc\Client::USE_CURL_NEVER); + + $this->$method(); } - function testHttpsProxy() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testHttpsProxy($method) { if(!function_exists('curl_init')) { - $this->markTestSkipped('CURL missing: cannot test https functionality'); + $this->markTestSkipped('CURL missing: cannot test https w. proxy'); return; } else if ($this->args['PROXYSERVER'] == '') { - $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1'); + $this->markTestSkipped('PROXYSERVER definition missing: cannot test proxy w. https'); + return; + } + else if ($this->args['HTTPSSERVER'] == '') + { + $this->markTestSkipped('HTTPS SERVER definition missing: cannot test https w. proxy'); return; } + $this->client->server = $this->args['HTTPSSERVER']; $this->method = 'https'; $this->client->method = 'https'; @@ -184,32 +298,83 @@ class LocalhostMultiTest extends LocalhostTest $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']); $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']); $this->client->setSSLVersion($this->args['SSLVERSION']); - $this->_runtests(); + + $this->$method(); } - function testUTF8Responses() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testUTF8Responses($method) { - //$this->client->path = strpos($URI, '?') === null ? $URI.'?RESPONSE_ENCODING=UTF-8' : $URI.'&RESPONSE_ENCODING=UTF-8'; - $this->client->path = $this->args['URI'].'?RESPONSE_ENCODING=UTF-8'; - $this->_runtests(); + $this->addQueryParams(array('RESPONSE_ENCODING' => 'UTF-8')); + + $this->$method(); } - function testUTF8Requests() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testUTF8Requests($method) { $this->client->request_charset_encoding = 'UTF-8'; - $this->_runtests(); + + $this->$method(); } - function testISOResponses() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testISOResponses($method) { - //$this->client->path = strpos($URI, '?') === null ? $URI.'?RESPONSE_ENCODING=UTF-8' : $URI.'&RESPONSE_ENCODING=UTF-8'; - $this->client->path = $this->args['URI'].'?RESPONSE_ENCODING=ISO-8859-1'; - $this->_runtests(); + $this->addQueryParams(array('RESPONSE_ENCODING' => 'ISO-8859-1')); + + $this->$method(); } - function testISORequests() + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testISORequests($method) { $this->client->request_charset_encoding = 'ISO-8859-1'; - $this->_runtests(); + + $this->$method(); + } + + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testBasicAuth($method) + { + $this->client->setCredentials('test', 'test'); + $this->addQueryParams(array('FORCE_AUTH' => 'Basic')); + + $this->$method(); + } + + /** + * @dataProvider getSingleHttpTestMethods + * @param string $method + */ + public function testDigestAuth($method) + { + if (!function_exists('curl_init')) + { + $this->markTestSkipped('CURL missing: cannot test digest auth functionality'); + return; + } + + $this->client->setCredentials('test', 'test', CURLAUTH_DIGEST); + $this->addQueryParams(array('FORCE_AUTH' => 'Digest')); + $this->method = 'http11'; + $this->client->method = 'http11'; + + $this->$method(); } }