From: gggeek Date: Sat, 23 May 2015 18:58:45 +0000 (+0100) Subject: Add one more test for wrap_method; add some comments to tests files; mark http tests... X-Git-Tag: 4.0.0-alpha^2~44 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=58c58d4953465ea14af366ddc2afc8d901715461 Add one more test for wrap_method; add some comments to tests files; mark http tests skipped when skipped instead of failed --- diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index 06fb36a..8ed214b 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -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(); diff --git a/tests/2InvalidHostTest.php b/tests/2InvalidHostTest.php index 0168c91..7e0062c 100644 --- a/tests/2InvalidHostTest.php +++ b/tests/2InvalidHostTest.php @@ -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 */ diff --git a/tests/3LocalhostTest.php b/tests/3LocalhostTest.php index be17d69..e205c9e 100644 --- a/tests/3LocalhostTest.php +++ b/tests/3LocalhostTest.php @@ -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 { diff --git a/tests/4LocalhostMultiTest.php b/tests/4LocalhostMultiTest.php index 5ef6a3c..9243514 100644 --- a/tests/4LocalhostMultiTest.php +++ b/tests/4LocalhostMultiTest.php @@ -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']; diff --git a/tests/5DemofilesTest.php b/tests/5DemofilesTest.php index 01ed621..3cbb5b4 100644 --- a/tests/5DemofilesTest.php +++ b/tests/5DemofilesTest.php @@ -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() diff --git a/tests/7ExtraTest.php b/tests/7ExtraTest.php index ff2d056..14488e8 100644 --- a/tests/7ExtraTest.php +++ b/tests/7ExtraTest.php @@ -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();