Add one more test for wrap_method; add some comments to tests files; mark http tests...
authorgggeek <giunta.gaetano@gmail.com>
Sat, 23 May 2015 18:58:45 +0000 (19:58 +0100)
committergggeek <giunta.gaetano@gmail.com>
Sat, 23 May 2015 18:58:45 +0000 (19:58 +0100)
tests/1ParsingBugsTest.php
tests/2InvalidHostTest.php
tests/3LocalhostTest.php
tests/4LocalhostMultiTest.php
tests/5DemofilesTest.php
tests/7ExtraTest.php

index 06fb36a..8ed214b 100644 (file)
@@ -5,6 +5,9 @@
 include_once __DIR__ . '/../lib/xmlrpc.inc';
 include_once __DIR__ . '/../lib/xmlrpcs.inc';
 
+/**
+ * Tests involving parsing of xml and handling of xmlrpc values
+ */
 class ParsingBugsTests extends PHPUnit_Framework_TestCase
 {
     public $args = array();
index 0168c91..7e0062c 100644 (file)
@@ -4,6 +4,9 @@ include_once __DIR__ . '/../lib/xmlrpc.inc';
 
 include_once __DIR__ . '/parse_args.php';
 
+/**
+ * Tests involving requests sent to non-existing servers
+ */
 class InvalidHostTest extends PHPUnit_Framework_TestCase
 {
     /** @var xmlrpc_client $client */
index be17d69..e205c9e 100644 (file)
@@ -5,6 +5,10 @@ include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc';
 
 include_once __DIR__ . '/parse_args.php';
 
+/**
+ * Tests which involve interaction between the client and the server.
+ * They are run against the server found in demo/server.php
+ */
 class LocalhostTest extends PHPUnit_Framework_TestCase
 {
     /** @var xmlrpc_client $client */
@@ -651,8 +655,8 @@ And turned it into nylon';
     public function testWrappedMethod()
     {
         // 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 == '') {
+        $func = wrap_xmlrpc_method($this->client, 'examples.getStateName', array('simple_client_copy' => 0));
+        if ($func == false) {
             $this->fail('Registration of examples.getStateName failed');
         } else {
             $v = $func(23);
@@ -664,10 +668,28 @@ And turned it into nylon';
         }
     }
 
+    public function testWrappedMethodAsSource()
+    {
+        // 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' => 0, 'return_source' => true));
+        if ($func == false) {
+            $this->fail('Registration of examples.getStateName failed');
+        } else {
+            eval($func['source']);
+            $func = $func['function'];
+            $v = $func(23);
+            // work around bug in current version of phpunit
+            if (is_object($v)) {
+                $v = var_export($v, true);
+            }
+            $this->assertEquals('Michigan', $v);
+        }
+    }
+
     public function testWrappedClass()
     {
         // make a 'deep client copy' as the original one might have many properties set
-        $class = wrap_xmlrpc_server($this->client, array('simple_client_copy' => 1));
+        $class = wrap_xmlrpc_server($this->client, array('simple_client_copy' => 0));
         if ($class == '') {
             $this->fail('Registration of remote server failed');
         } else {
index 5ef6a3c..9243514 100644 (file)
@@ -7,6 +7,10 @@ include_once __DIR__ . '/parse_args.php';
 
 include_once __DIR__ . '/3LocalhostTest.php';
 
+/**
+ * Tests which stress http features of the library.
+ * Each of these tests iterates over (almost) all of the 'localhost' tests
+ */
 class LocalhostMultiTest extends LocalhostTest
 {
     /**
@@ -34,7 +38,7 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('gzdeflate'))
         {
-            $this->fail('Zlib missing: cannot test deflate functionality');
+            $this->markTestSkipped('Zlib missing: cannot test deflate functionality');
             return;
         }
         $this->client->accepted_compression = array('deflate');
@@ -46,7 +50,7 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('gzdeflate'))
         {
-            $this->fail('Zlib missing: cannot test gzip functionality');
+            $this->markTestSkipped('Zlib missing: cannot test gzip functionality');
             return;
         }
         $this->client->accepted_compression = array('gzip');
@@ -58,7 +62,7 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('curl_init'))
         {
-            $this->fail('CURL missing: cannot test http 1.1');
+            $this->markTestSkipped('CURL missing: cannot test http 1.1');
             return;
         }
         $this->method = 'http11';
@@ -74,14 +78,14 @@ class LocalhostMultiTest extends LocalhostTest
             $this->_runtests();
         }
         else
-            $this->fail('PROXY definition missing: cannot test proxy');
+            $this->markTestSkipped('PROXY definition missing: cannot test proxy');
     }
 
     function testHttp11()
     {
         if(!function_exists('curl_init'))
         {
-            $this->fail('CURL missing: cannot test http 1.1');
+            $this->markTestSkipped('CURL missing: cannot test http 1.1');
             return;
         }
         $this->method = 'http11'; // not an error the double assignment!
@@ -96,7 +100,7 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('curl_init'))
         {
-            $this->fail('CURL missing: cannot test http 1.1');
+            $this->markTestSkipped('CURL missing: cannot test http 1.1');
             return;
         }
         $this->method = 'http11'; // not an error the double assignment!
@@ -111,7 +115,7 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('curl_init'))
         {
-            $this->fail('CURL missing: cannot test http 1.1');
+            $this->markTestSkipped('CURL missing: cannot test http 1.1');
             return;
         }
         $this->method = 'http11'; // not an error the double assignment!
@@ -126,12 +130,12 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('curl_init'))
         {
-            $this->fail('CURL missing: cannot test http 1.1 w. proxy');
+            $this->markTestSkipped('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');
+            $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1');
             return;
         }
         $this->method = 'http11'; // not an error the double assignment!
@@ -147,7 +151,7 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('curl_init'))
         {
-            $this->fail('CURL missing: cannot test https functionality');
+            $this->markTestSkipped('CURL missing: cannot test https functionality');
             return;
         }
         $this->client->server = $this->args['HTTPSSERVER'];
@@ -164,12 +168,12 @@ class LocalhostMultiTest extends LocalhostTest
     {
         if(!function_exists('curl_init'))
         {
-            $this->fail('CURL missing: cannot test https functionality');
+            $this->markTestSkipped('CURL missing: cannot test https functionality');
             return;
         }
         else if ($this->args['PROXYSERVER'] == '')
         {
-            $this->fail('PROXY definition missing: cannot test proxy w. http 1.1');
+            $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1');
             return;
         }
         $this->client->server = $this->args['HTTPSSERVER'];
index 01ed621..3cbb5b4 100644 (file)
@@ -2,6 +2,9 @@
 
 include_once __DIR__ . '/LocalFileTestCase.php';
 
+/**
+ * Tests for php files in the 'demo' directory
+ */
 class DemoFilesTest extends PhpXmlRpc_LocalFileTestCase
 {
     public function setUp()
index ff2d056..14488e8 100644 (file)
@@ -2,9 +2,11 @@
 
 include_once __DIR__ . '/LocalFileTestCase.php';
 
+/**
+ * Tests for php files in the 'extras' directory
+ */
 class ExtraTest extends PhpXmlRpc_LocalFileTestCase
 {
-
     public function setUp()
     {
         $this->args = argParser::getArgs();