tests
authorgggeek <giunta.gaetano@gmail.com>
Wed, 25 Jan 2023 16:27:48 +0000 (16:27 +0000)
committergggeek <giunta.gaetano@gmail.com>
Wed, 25 Jan 2023 16:27:48 +0000 (16:27 +0000)
tests/02ValueTest.php
tests/03MessagesTest.php [new file with mode: 0644]
tests/04ParsingTest.php [moved from tests/03ParsingTest.php with 99% similarity]
tests/05LoggerTest.php [moved from tests/04LoggerTest.php with 100% similarity]
tests/06EncoderTest.php
tests/07ClientTest.php

index 82a4295..ffd8b1d 100644 (file)
@@ -13,7 +13,7 @@ use PHPUnit\Runner\BaseTestRunner;
  * Tests involving the Value class.
  * NB: these tests do not involve the parsing of xml into Value objects - look in 03ParsingTest for that
  */
-class ValueTests extends PhpXmlRpc_PolyfillTestCase
+class ValueTest extends PhpXmlRpc_PolyfillTestCase
 {
     public $args = array();
 
diff --git a/tests/03MessagesTest.php b/tests/03MessagesTest.php
new file mode 100644 (file)
index 0000000..b6c4a3f
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+
+include_once __DIR__ . '/../lib/xmlrpc.inc';
+include_once __DIR__ . '/../lib/xmlrpcs.inc';
+
+include_once __DIR__ . '/parse_args.php';
+
+include_once __DIR__ . '/PolyfillTestCase.php';
+
+use PHPUnit\Runner\BaseTestRunner;
+
+/**
+ * Tests involving Requests and Responses, except for the parsing part
+ */
+class MessagesTest extends PhpXmlRpc_PolyfillTestCase
+{
+    public $args = array();
+
+    protected function set_up()
+    {
+        $this->args = argParser::getArgs();
+        // hide parsing errors unless in debug mode
+        if ($this->args['DEBUG'] == 1)
+            ob_start();
+    }
+
+    protected function tear_down()
+    {
+        if ($this->args['DEBUG'] != 1)
+            return;
+        $out = ob_get_clean();
+        $status = $this->getStatus();
+        if ($status == BaseTestRunner::STATUS_ERROR
+            || $status == BaseTestRunner::STATUS_FAILURE) {
+            echo $out;
+        }
+    }
+
+    public function testSerializePHPValResponse()
+    {
+        $r = new \PhpXmlRpc\Response(array('hello' => 'world'), 0, '', 'phpvals');
+        $v = $r->serialize();
+        $this->assertStringContainsString('<member><name>hello</name>', $v);
+        $this->assertStringContainsString('<value><string>world</string></value>', $v);
+    }
+}
similarity index 99%
rename from tests/03ParsingTest.php
rename to tests/04ParsingTest.php
index 70c81c0..2a5831a 100644 (file)
@@ -14,7 +14,7 @@ use PHPUnit\Runner\BaseTestRunner;
  *
  * @todo some tests are here even though they logically belong elsewhere...
  */
-class ParsingTests extends PhpXmlRpc_PolyfillTestCase
+class ParsingTest extends PhpXmlRpc_PolyfillTestCase
 {
     public $args = array();
 
index 59ba798..4323ed4 100644 (file)
@@ -15,7 +15,7 @@ use PHPUnit\Runner\BaseTestRunner;
  * @todo add tests for encoding options: 'encode_php_objs', 'auto_dates', 'null_extension' and 'extension_api'
  * @todo add tests for php_xmlrpc_decode options
  */
-class EncoderTests extends PhpXmlRpc_PolyfillTestCase
+class EncoderTest extends PhpXmlRpc_PolyfillTestCase
 {
     public $args = array();
 
index dd2ab40..3490503 100644 (file)
@@ -11,7 +11,7 @@ use PHPUnit\Runner\BaseTestRunner;
 /**
  * Tests involving the Client class (and no server).
  */
-class ClientTest extends PhpXmlRpc_PolyfillTestCase
+class ClientTes extends PhpXmlRpc_PolyfillTestCase
 {
     /** @var xmlrpc_client $client */
     public $client = null;