set https options for tests
[plcapi.git] / test / testsuite.php
index 0164c66..e5fb6d8 100644 (file)
@@ -228,8 +228,12 @@ And turned it into nylon';
         if (class_exists('DateTime'))
         {
             $datetime = new DateTime();
-            $t3 = new xmlrpcval($datetime->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);
         }
     }
@@ -634,7 +644,9 @@ class LocalHostMultiTests extends LocalhostTests
             if(strpos($meth, 'test') === 0 && $meth != 'testHttps' && $meth != 'testCatchExceptions')
             {
                 if (!isset($failed_tests[$meth]))
+                {
                     $this->$meth();
+                }
             }
             if ($this->_failed)
             {
@@ -762,7 +774,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');
@@ -772,13 +784,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, $NOPROXY;
+        global $HTTPSSERVER, $HTTPSURI, $HTTPSIGNOREPEER, $HTTPSVERIFYHOST, $PROXYSERVER, $PROXYPORT, $NOPROXY;
         if(!function_exists('curl_init'))
         {
             $this->fail('CURL missing: cannot test https functionality');
@@ -795,6 +808,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();
     }
 
@@ -874,7 +889,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()
@@ -1526,6 +1541,10 @@ Proxy Server: <input name="PROXY" size="30" value="<?php echo isset($PROXY) ? ht
 </form>
 </div>
 <?php
-echo $result->toHTML()."\n</body>\n</html>\n";
+    echo $result->toHTML()."\n</body>\n</html>\n";
+}
+else
+{
+    exit($result->failureCount());
 }
 ?>
\ No newline at end of file