From f1e595deaca76bd28257adb82916624ac59eb5b1 Mon Sep 17 00:00:00 2001 From: gggeek Date: Fri, 11 Dec 2020 11:45:46 +0000 Subject: [PATCH] tests --- debugger/action.php | 2 +- debugger/controller.php | 2 +- debugger/index.php | 2 +- demo/client/_bootstrap.php | 25 +++++++++++++++++++++++++ demo/client/agesort.php | 11 ++++------- demo/client/getstatename.php | 11 +++++------ demo/client/introspect.php | 8 +++----- demo/client/mail.php | 14 ++++---------- demo/client/proxy.php | 9 +++------ demo/client/which.php | 9 ++++----- demo/client/wrap.php | 11 +++++------ demo/server/_bootstrap.php | 18 ++++++++++++++++++ demo/server/discuss.php | 2 +- demo/server/proxy.php | 7 +++---- demo/server/server.php | 8 +------- tests/LocalFileTestCase.php | 2 -- tests/parse_args.php | 12 +++--------- 17 files changed, 82 insertions(+), 71 deletions(-) create mode 100644 demo/client/_bootstrap.php create mode 100644 demo/server/_bootstrap.php diff --git a/debugger/action.php b/debugger/action.php index 216c2c39..0474bfef 100644 --- a/debugger/action.php +++ b/debugger/action.php @@ -14,7 +14,7 @@ header('Content-Type: text/html; charset=utf-8'); ?> - + XMLRPC Debugger diff --git a/debugger/controller.php b/debugger/controller.php index 94c7410d..46c1759a 100644 --- a/debugger/controller.php +++ b/debugger/controller.php @@ -26,7 +26,7 @@ $editorlibs = '../../phpjsrpc/lib/'; ?> - + XMLRPC Debugger diff --git a/debugger/index.php b/debugger/index.php index eff10ea9..a8c0b551 100644 --- a/debugger/index.php +++ b/debugger/index.php @@ -9,7 +9,7 @@ if (isset($_GET['run'])) { ?> - + XMLRPC Debugger diff --git a/demo/client/_bootstrap.php b/demo/client/_bootstrap.php new file mode 100644 index 00000000..d705d64a --- /dev/null +++ b/demo/client/_bootstrap.php @@ -0,0 +1,25 @@ + + xmlrpc - Agesort demo

Agesort demo

@@ -7,12 +7,9 @@

The source code demonstrates basic lib usage, including handling of xmlrpc arrays and structs

-

+

You can see the source to this page here: agesort.php

24, "Edd" => 45, "Joe" => 37, "Fred" => 27); print "This is the input data:
";
 foreach ($inAr as $key => $val) {
@@ -20,7 +17,7 @@ foreach ($inAr as $key => $val) {
 }
 print "
"; -// create parameters from the input array: an xmlrpc array of xmlrpc structs +// Create parameters from the input array: an xmlrpc array of xmlrpc structs $p = array(); foreach ($inAr as $key => $val) { $p[] = new PhpXmlRpc\Value( @@ -36,7 +33,7 @@ print "Encoded into xmlrpc format it looks like this:
\n" . htmlentities($v
 
 // create client and message objects
 $req = new PhpXmlRpc\Request('examples.sortByAge', array($v));
-$client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
+$client = new PhpXmlRpc\Client(XMLRPCSERVER);
 
 // set maximum debug level, to have the complete communication printed to screen
 $client->setDebug(2);
diff --git a/demo/client/getstatename.php b/demo/client/getstatename.php
index 69ce3e0f..304bf258 100644
--- a/demo/client/getstatename.php
+++ b/demo/client/getstatename.php
@@ -1,4 +1,4 @@
-
+
 xmlrpc - Getstatename demo
 
 

Getstatename demo

@@ -6,10 +6,9 @@

Send a U.S. state number to the server and get back the state name

The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values

-You can see the source to this page here: getstatename.php

+encode($stateNo)) ); print "Sending the following request:
\n\n" . htmlentities($req->serialize()) . "\n\n
Debug info of server data follows...\n\n"; - $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php"); + $client = new PhpXmlRpc\Client(XMLRPCSERVER); $client->setDebug(1); $r = $client->send($req); if (!$r->faultCode()) { $v = $r->value(); print "
State number " . $stateNo . " is " - . htmlspecialchars($encoder->decode($v)) . "
"; + . htmlspecialchars($encoder->decode($v)) . "

"; } else { print "An error occurred: "; print "Code: " . htmlspecialchars($r->faultCode()) diff --git a/demo/client/introspect.php b/demo/client/introspect.php index 478d43bd..57df9186 100644 --- a/demo/client/introspect.php +++ b/demo/client/introspect.php @@ -1,14 +1,12 @@ - + xmlrpc - Introspect demo

Introspect demo

Query server for available methods and their description

The code demonstrates usage of multicall and introspection methods

+

You can see the source to this page here: introspect.php

faultString() . "'
"; } -$client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php"); +$client = new PhpXmlRpc\Client(XMLRPCSERVER); // First off, let's retrieve the list of methods available on the remote server print "

methods available at http://" . $client->server . $client->path . "

\n"; diff --git a/demo/client/mail.php b/demo/client/mail.php index 7ac6e78d..32a4a1f0 100644 --- a/demo/client/mail.php +++ b/demo/client/mail.php @@ -1,11 +1,4 @@ - - + xmlrpc - Mail demo

Mail demo

@@ -14,17 +7,18 @@ if (isset($_GET['showSource']) && $_GET['showSource']) { When you press Send this page will reload, showing you the XML-RPC request sent to the host server, the XML-RPC response received and the internal evaluation done by the PHP implementation.

-

You can find the source to this page here: mail.php
+

You can see the source to this page here: mail.php
And the source to a functionally identical mail-by-XML-RPC server in the file server.php included with the library (look for the 'mail_send' method)

+ xmlrpc - Proxy demo

proxy demo

Query server using a 'proxy' object

The code demonstrates usage for the terminally lazy. For a more complete proxy, look at at the Wrapper class

+

You can see the source to this page here: proxy.php

value(); } } - } $stateNo = rand(1, 51); -$proxy = new PhpXmlRpcProxy(new \PhpXmlRpc\Client('http://phpxmlrpc.sourceforge.net/server.php')); +$proxy = new PhpXmlRpcProxy(new \PhpXmlRpc\Client(XMLRPCSERVER)); $stateName = $proxy->getStateName($stateNo); echo "State $stateNo is ".htmlspecialchars($stateName); diff --git a/demo/client/which.php b/demo/client/which.php index 5d332159..6664e2f0 100644 --- a/demo/client/which.php +++ b/demo/client/which.php @@ -1,20 +1,19 @@ - + xmlrpc - Which toolkit demo

Which toolkit demo

Query server for toolkit information

The code demonstrates usage of the PhpXmlRpc\Encoder class

+

You can see the source to this page here: which.php

send($req); if (!$resp->faultCode()) { $encoder = new PhpXmlRpc\Encoder(); $value = $encoder->decode($resp->value()); + print "Toolkit info:
\n"; print "
";
     print "name: " . htmlspecialchars($value["toolkitName"]) . "\n";
     print "version: " . htmlspecialchars($value["toolkitVersion"]) . "\n";
diff --git a/demo/client/wrap.php b/demo/client/wrap.php
index c13c55d3..88d6a8d2 100644
--- a/demo/client/wrap.php
+++ b/demo/client/wrap.php
@@ -1,4 +1,4 @@
-
+
 xmlrpc - Webservice wrappper demo
 
 

Webservice wrappper demo

@@ -10,12 +10,10 @@ 2) wrapping of remote methods into php functions
See also proxy.php for an alternative take +

You can see the source to this page here: wrap.php

return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals $resp = $client->send(new PhpXmlRpc\Request('system.listMethods')); if ($resp->faultCode()) { @@ -44,8 +42,9 @@ if ($resp->faultCode()) { if ($callable) { echo "Now testing function for remote method to convert U.S. state number into state name"; $stateNum = rand(1, 51); - // the 2nd parameter gets added to the closure - it is teh debug level to be used for the client + // the 2nd parameter gets added to the closure - it is the debug level to be used for the client $stateName = $callable($stateNum, 2); + echo "State $stateNum is ".htmlspecialchars($stateName); } } ?> diff --git a/demo/server/_bootstrap.php b/demo/server/_bootstrap.php new file mode 100644 index 00000000..b16296e9 --- /dev/null +++ b/demo/server/_bootstrap.php @@ -0,0 +1,18 @@ +decode($req->getParam(1)); $pars = $req->getParam(2); $req = new PhpXmlRpc\Request($reqMethod); diff --git a/demo/server/server.php b/demo/server/server.php index d8366749..6e9fdf96 100644 --- a/demo/server/server.php +++ b/demo/server/server.php @@ -9,13 +9,7 @@ * Please do not copy this file verbatim into your production server. **/ -// give user a chance to see the source for this server instead of running the services -if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource'])) { - highlight_file(__FILE__); - die(); -} - -include_once __DIR__ . "/../../vendor/autoload.php"; +require_once __DIR__ . "/_bootstrap.php"; // out-of-band information: let the client manipulate the server operations. // we do this to help the testsuite script: do not reproduce in production! diff --git a/tests/LocalFileTestCase.php b/tests/LocalFileTestCase.php index 6ec48b32..13160c71 100644 --- a/tests/LocalFileTestCase.php +++ b/tests/LocalFileTestCase.php @@ -4,8 +4,6 @@ include_once __DIR__ . '/parse_args.php'; include_once __DIR__ . '/PolyfillTestCase.php'; -use PHPUnit\Framework\TestResult; - abstract class PhpXmlRpc_LocalFileTestCase extends PhpXmlRpc_PolyfillTestCase { public $args = array(); diff --git a/tests/parse_args.php b/tests/parse_args.php index 4ef568d3..f9c45629 100644 --- a/tests/parse_args.php +++ b/tests/parse_args.php @@ -7,12 +7,11 @@ * @param string LOCALSERVER * @param string URI * @param string HTTPSSERVER - * @param string HTTPSSURI - * @param string PROXY - * @param string NOPROXY + * @param string HTTPSURI * @param bool HTTPSIGNOREPEER * @param int HTTPSVERIFYHOST * @param int SSLVERSION + * @param string PROXYSERVER * * @copyright (C) 2007-2020 G. Giunta * @license code licensed under the BSD License: see file license.txt @@ -24,13 +23,12 @@ class argParser $args = array( 'DEBUG' => 0, 'LOCALSERVER' => 'localhost', - 'HTTPSSERVER' => 'gggeek.ssl.altervista.org', + 'HTTPSSERVER' => 'gggeek.altervista.org', 'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php', 'HTTPSIGNOREPEER' => false, 'HTTPSVERIFYHOST' => 2, 'SSLVERSION' => 0, 'PROXYSERVER' => null, - //'NOPROXY' => false, 'LOCALPATH' => __DIR__, ); @@ -83,10 +81,6 @@ class argParser $args['PROXYPORT'] = 8080; } } - // used to silence testsuite warnings about proxy code not being tested - //if (isset($NOPROXY)) { - // $args['NOPROXY'] = true; - //} if (!isset($URI)) { // GUESTIMATE the url of local demo server // play nice to php 3 and 4-5 in retrieving URL of server.php -- 2.47.0