From: gggeek Date: Fri, 20 Mar 2015 01:54:52 +0000 (+0000) Subject: Add the multiTest suite; minor test fixes X-Git-Tag: 4.0.0-alpha^2~163 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=964c756207a405a0aa24722bab26ad0e8ab4fcd1;p=plcapi.git Add the multiTest suite; minor test fixes --- diff --git a/tests/InvalidHostTest.php b/tests/InvalidHostTest.php index 1ac111f7..685bd598 100644 --- a/tests/InvalidHostTest.php +++ b/tests/InvalidHostTest.php @@ -6,6 +6,7 @@ include_once __DIR__ . '/parse_args.php'; class InvalidHostTest extends PHPUnit_Framework_TestCase { + /** @var xmlrpc_client $client */ public $client = null; public $args = array(); diff --git a/tests/LocalhostMultiTest.php b/tests/LocalhostMultiTest.php new file mode 100644 index 00000000..e855f216 --- /dev/null +++ b/tests/LocalhostMultiTest.php @@ -0,0 +1,206 @@ +$method(); + } + /*if ($this->_failed) + { + break; + }*/ + } + } + + function testDeflate() + { + if(!function_exists('gzdeflate')) + { + $this->fail('Zlib missing: cannot test deflate functionality'); + return; + } + $this->client->accepted_compression = array('deflate'); + $this->client->request_compression = 'deflate'; + $this->_runtests(); + } + + function testGzip() + { + if(!function_exists('gzdeflate')) + { + $this->fail('Zlib missing: cannot test gzip functionality'); + return; + } + $this->client->accepted_compression = array('gzip'); + $this->client->request_compression = 'gzip'; + $this->_runtests(); + } + + function testKeepAlives() + { + if(!function_exists('curl_init')) + { + $this->fail('CURL missing: cannot test http 1.1'); + return; + } + $this->method = 'http11'; + $this->client->keepalive = true; + $this->_runtests(); + } + + function testProxy() + { + if ($this->args['PROXYSERVER']) + { + $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']); + $this->_runtests(); + } + else + $this->fail('PROXY definition missing: cannot test proxy'); + } + + function testHttp11() + { + if(!function_exists('curl_init')) + { + $this->fail('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(); + } + + function testHttp11Gzip() + { + if(!function_exists('curl_init')) + { + $this->fail('CURL missing: cannot test http 1.1'); + return; + } + $this->method = 'http11'; // not an error the double assignment! + $this->client->method = 'http11'; + $this->client->keepalive = false; + $this->client->accepted_compression = array('gzip'); + $this->client->request_compression = 'gzip'; + $this->_runtests(); + } + + function testHttp11Deflate() + { + if(!function_exists('curl_init')) + { + $this->fail('CURL missing: cannot test http 1.1'); + return; + } + $this->method = 'http11'; // not an error the double assignment! + $this->client->method = 'http11'; + $this->client->keepalive = false; + $this->client->accepted_compression = array('deflate'); + $this->client->request_compression = 'deflate'; + $this->_runtests(); + } + + function testHttp11Proxy() + { + if(!function_exists('curl_init')) + { + $this->fail('CURL missing: cannot test http 1.1 w. proxy'); + return; + } + else if ($this->args['PROXYSERVER'] == '') + { + $this->fail('PROXY 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(); + } + + function testHttps() + { + if(!function_exists('curl_init')) + { + $this->fail('CURL missing: cannot test https functionality'); + 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->_runtests(); + } + + function testHttpsProxy() + { + if(!function_exists('curl_init')) + { + $this->fail('CURL missing: cannot test https functionality'); + return; + } + else if ($this->args['PROXYSERVER'] == '') + { + $this->fail('PROXY definition missing: cannot test proxy w. http 1.1'); + return; + } + $this->client->server = $this->args['HTTPSSERVER']; + $this->method = 'https'; + $this->client->method = 'https'; + $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']); + $this->client->path = $this->args['HTTPSURI']; + $this->client->setSSLVerifyPeer( !$this->args['HTTPSIGNOREPEER'] ); + $this->_runtests(); + } + + function testUTF8Responses() + { + //$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(); + } + + function testUTF8Requests() + { + $this->client->request_charset_encoding = 'UTF-8'; + $this->_runtests(); + } + + function testISOResponses() + { + //$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(); + } + + function testISORequests() + { + $this->client->request_charset_encoding = 'ISO-8859-1'; + $this->_runtests(); + } +} diff --git a/tests/LocalhostTest.php b/tests/LocalhostTest.php index 90822518..562dbb51 100644 --- a/tests/LocalhostTest.php +++ b/tests/LocalhostTest.php @@ -7,6 +7,7 @@ include_once __DIR__ . '/parse_args.php'; class LocalhostTest extends PHPUnit_Framework_TestCase { + /** @var xmlrpc_client $client */ public $client = null; public $method = 'http'; public $timeout = 10; @@ -14,6 +15,8 @@ class LocalhostTest extends PHPUnit_Framework_TestCase public $accepted_compression = ''; public $args = array(); + protected static $failed_tests = array(); + public static function fail($message = '') { // save in global var that this particular test has failed @@ -23,7 +26,7 @@ class LocalhostTest extends PHPUnit_Framework_TestCase $trace = debug_backtrace(); for ($i = 0; $i < count($trace); $i++) { if (strpos($trace[$i]['function'], 'test') === 0) { - $failed_tests[$trace[$i]['function']] = true; + self::$failed_tests[$trace[$i]['function']] = true; break; } } diff --git a/tests/parse_args.php b/tests/parse_args.php index 744afbff..e9f2e2eb 100644 --- a/tests/parse_args.php +++ b/tests/parse_args.php @@ -67,7 +67,7 @@ class argParser $args['HTTPSURI'] = $HTTPSURI; } if (isset($HTTPSIGNOREPEER)) { - $args['HTTPSIGNOREPEER'] = bool($HTTPSIGNOREPEER); + $args['HTTPSIGNOREPEER'] = (bool)$HTTPSIGNOREPEER; } if (isset($PROXY)) { $arr = explode(':', $PROXY);