X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=test%2Ftestsuite.php;h=19a4f0eb2d42a2aa99cd50154568a6e98b0030b8;hb=0c9070eabdf0710e722a5f080d11ff4f1cf7197c;hp=dbbfa0b1b1031590d8ced5eb724d0348e4943400;hpb=2c732850d51db98da039e49e018b342d2a4e0242;p=plcapi.git diff --git a/test/testsuite.php b/test/testsuite.php index dbbfa0b..19a4f0e 100644 --- a/test/testsuite.php +++ b/test/testsuite.php @@ -1,6 +1,6 @@ setTimestamp($time), 'dateTime.iso8601'); - $this->assertEquals($t1->serialize(), $t3->serialize()); + // skip this test for php 5.2. It is a bit harder there to build a DateTime from unix timestamp with proper TZ info + if(is_callable(array($datetime,'setTimestamp'))) + { + $t3 = new xmlrpcval($datetime->setTimestamp($time), 'dateTime.iso8601'); + $this->assertEquals($t1->serialize(), $t3->serialize()); + } } } @@ -530,7 +534,8 @@ And turned it into nylon'; function testAutoRegisteredMethod() { - $func=wrap_xmlrpc_method($this->client, 'examples.getStateName'); + // make a 'deep client copy' as the original one might have many properties set + $func=wrap_xmlrpc_method($this->client, 'examples.getStateName', array('simple_client_copy' => 1)); if($func == '') { $this->fail('Registration of examples.getStateName failed'); @@ -538,6 +543,11 @@ And turned it into nylon'; else { $v=$func(23); + // work around bug in current version of phpunit + if(is_object($v)) + { + $v = var_export($v, true); + } $this->assertEquals('Michigan', $v); } } @@ -561,6 +571,17 @@ And turned it into nylon'; $this->assertEquals(1, $v->scalarval()); // now check if we decoded the cookies as we had set them $rcookies = $r->cookies(); + // remove extra cookies which might have been set by proxies + foreach($rcookies as $c => $v) + { + if(!in_array($c, array('c2', 'c3', 'c4', 'c5'))) + unset($rcookies[$c]); + // Seems like we get this when using php-fpm and php 5.5+ ... + if (isset($rcookies[$c]['Max-Age'])) + { + unset($rcookies[$c]['Max-Age']); + } + } foreach($cookies as $c => $v) // format for date string in cookies: 'Mon, 31 Oct 2005 13:50:56 GMT' // but PHP versions differ on that, some use 'Mon, 31-Oct-2005 13:50:56 GMT'... @@ -630,7 +651,9 @@ class LocalHostMultiTests extends LocalhostTests if(strpos($meth, 'test') === 0 && $meth != 'testHttps' && $meth != 'testCatchExceptions') { if (!isset($failed_tests[$meth])) + { $this->$meth(); + } } if ($this->_failed) { @@ -677,14 +700,15 @@ class LocalHostMultiTests extends LocalhostTests function testProxy() { - global $PROXYSERVER, $PROXYPORT; + global $PROXYSERVER, $PROXYPORT, $NOPROXY; if ($PROXYSERVER) { $this->client->setProxy($PROXYSERVER, $PROXYPORT); $this->_runtests(); } else - $this->fail('PROXY definition missing: cannot test proxy'); + if (!$NOPROXY) + $this->fail('PROXY definition missing: cannot test proxy'); } function testHttp11() @@ -734,7 +758,7 @@ class LocalHostMultiTests extends LocalhostTests function testHttp11Proxy() { - global $PROXYSERVER, $PROXYPORT; + global $PROXYSERVER, $PROXYPORT, $NOPROXY; if(!function_exists('curl_init')) { $this->fail('CURL missing: cannot test http 1.1 w. proxy'); @@ -742,7 +766,8 @@ class LocalHostMultiTests extends LocalhostTests } else if ($PROXYSERVER == '') { - $this->fail('PROXY definition missing: cannot test proxy w. http 1.1'); + if (!$NOPROXY) + $this->fail('PROXY definition missing: cannot test proxy w. http 1.1'); return; } $this->method = 'http11'; // not an error the double assignment! @@ -756,7 +781,7 @@ class LocalHostMultiTests extends LocalhostTests function testHttps() { - global $HTTPSSERVER, $HTTPSURI, $HTTPSIGNOREPEER; + global $HTTPSSERVER, $HTTPSURI, $HTTPSIGNOREPEER, $HTTPSVERIFYHOST; if(!function_exists('curl_init')) { $this->fail('CURL missing: cannot test https functionality'); @@ -766,13 +791,14 @@ class LocalHostMultiTests extends LocalhostTests $this->method = 'https'; $this->client->method = 'https'; $this->client->path = $HTTPSURI; - $this->client->setSSLVerifyPeer( !$HTTPSIGNOREPEER ); + $this->client->setSSLVerifyPeer(!$HTTPSIGNOREPEER); + $this->client->setSSLVerifyHost($HTTPSVERIFYHOST); $this->_runtests(); } function testHttpsProxy() { - global $HTTPSSERVER, $HTTPSURI, $PROXYSERVER, $PROXYPORT;; + global $HTTPSSERVER, $HTTPSURI, $HTTPSIGNOREPEER, $HTTPSVERIFYHOST, $PROXYSERVER, $PROXYPORT, $NOPROXY; if(!function_exists('curl_init')) { $this->fail('CURL missing: cannot test https functionality'); @@ -780,7 +806,8 @@ class LocalHostMultiTests extends LocalhostTests } else if ($PROXYSERVER == '') { - $this->fail('PROXY definition missing: cannot test proxy w. http 1.1'); + if (!$NOPROXY) + $this->fail('PROXY definition missing: cannot test proxy w. http 1.1'); return; } $this->client->server = $HTTPSSERVER; @@ -788,6 +815,8 @@ class LocalHostMultiTests extends LocalhostTests $this->client->method = 'https'; $this->client->setProxy($PROXYSERVER, $PROXYPORT); $this->client->path = $HTTPSURI; + $this->client->setSSLVerifyPeer(!$HTTPSIGNOREPEER); + $this->client->setSSLVerifyHost($HTTPSVERIFYHOST); $this->_runtests(); } @@ -867,7 +896,7 @@ class ParsingBugsTests extends PHPUnit_TestCase $m=new xmlrpcmsg('dummy'); $r=$m->parseResponse($response); $v=$r->faultString(); - $this->assertEquals('���àüè', $v); + $this->assertEquals('������', $v); } function testValidNumbers() @@ -1519,6 +1548,10 @@ Proxy Server: \n\n"; + echo $result->toHTML()."\n\n\n"; +} +else +{ + exit($result->failureCount()); } ?> \ No newline at end of file