From 14eb2f33f3e65a67cc1f5008a5c11090fd3a4185 Mon Sep 17 00:00:00 2001 From: gggeek Date: Sat, 26 Nov 2022 11:22:49 +0000 Subject: [PATCH] clean up demo code from testsuite needs --- debugger/action.php | 3 --- debugger/controller.php | 3 --- debugger/index.php | 3 --- demo/client/_append.php | 7 ------ demo/client/_prepend.php | 16 -------------- demo/client/agesort.php | 2 -- demo/client/getstatename.php | 2 -- demo/client/introspect.php | 3 --- demo/client/mail.php | 2 -- demo/client/parallel.php | 3 --- demo/client/proxy.php | 2 -- demo/client/which.php | 2 -- demo/client/wrap.php | 2 -- demo/server/_append.php | 7 ------ demo/server/_prepend.php | 16 -------------- demo/server/discuss.php | 2 -- demo/server/proxy.php | 2 -- demo/server/server.php | 2 -- demo/vardemo.php | 2 -- phpunit.xml.dist | 1 - tests/4ClientTest.php | 2 +- tests/5ServerTest.php | 7 +++--- tests/6HTTPTest.php | 2 +- tests/7DemofilesTest.php | 28 ++++++++++++------------ tests/8DebuggerTest.php | 10 ++++----- tests/9ExtraFilesTest.php | 17 +++++---------- tests/ci/config/apache_vhost | 2 -- tests/index.php | 42 ++++++++++++++++++++++++++++++++++++ 28 files changed, 72 insertions(+), 120 deletions(-) delete mode 100644 demo/client/_append.php delete mode 100644 demo/server/_append.php create mode 100644 tests/index.php diff --git a/debugger/action.php b/debugger/action.php index 9dacf155..7e35a22e 100644 --- a/debugger/action.php +++ b/debugger/action.php @@ -9,8 +9,6 @@ * @todo be smarter in creating client stub for proxy/auth cases: only set appropriate property of client obj **/ -if (getenv('TESTMODE') === 'true') require_once __DIR__ . "/../demo/server/_prepend.php"; - header('Content-Type: text/html; charset=utf-8'); ?> @@ -565,4 +563,3 @@ if ($action) { ?> - diff --git a/debugger/controller.php b/debugger/controller.php index 1fcfea94..1501ac03 100644 --- a/debugger/controller.php +++ b/debugger/controller.php @@ -14,8 +14,6 @@ * @todo if js libs are not available, do not try to load them **/ -if (getenv('TESTMODE') === 'true') require_once __DIR__ . "/../demo/server/_prepend.php"; - // Make sure we set the correct charset type for output, so that we can display all characters header('Content-Type: text/html; charset=utf-8'); @@ -361,4 +359,3 @@ $editorlibs = (defined('JSXMLRPC_PATH') ? JSXMLRPC_PATH : '../..') . '/jsxmlrpc/ - diff --git a/debugger/index.php b/debugger/index.php index 7da44089..2e718d4e 100644 --- a/debugger/index.php +++ b/debugger/index.php @@ -1,7 +1,5 @@ - diff --git a/demo/client/_append.php b/demo/client/_append.php deleted file mode 100644 index e235edfc..00000000 --- a/demo/client/_append.php +++ /dev/null @@ -1,7 +0,0 @@ -faultCode()) { } output("\n"); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/client/getstatename.php b/demo/client/getstatename.php index 89b56cd7..2f7df378 100644 --- a/demo/client/getstatename.php +++ b/demo/client/getstatename.php @@ -40,5 +40,3 @@ output("

Enter a state number to query its name

"); output("\n"); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/client/introspect.php b/demo/client/introspect.php index b4a0dca1..b5fe3365 100644 --- a/demo/client/introspect.php +++ b/demo/client/introspect.php @@ -1,5 +1,4 @@ @@ -84,5 +83,3 @@ if ($resp->faultCode()) { } output("\n"); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/client/mail.php b/demo/client/mail.php index cd726b54..06f1db89 100644 --- a/demo/client/mail.php +++ b/demo/client/mail.php @@ -56,5 +56,3 @@ output(' '); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/client/parallel.php b/demo/client/parallel.php index ace50e72..db302a19 100644 --- a/demo/client/parallel.php +++ b/demo/client/parallel.php @@ -1,5 +1,4 @@ send($reqs); $t = microtime(true) - $t; echo "Multicall send: $t secs\n"; - -require_once __DIR__ . "/_append.php"; diff --git a/demo/client/proxy.php b/demo/client/proxy.php index 8e89e81e..12b0a158 100644 --- a/demo/client/proxy.php +++ b/demo/client/proxy.php @@ -76,5 +76,3 @@ $stateName = $proxy->getStateName($stateNo); output("State $stateNo is ".htmlspecialchars($stateName)); output("\n"); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/client/which.php b/demo/client/which.php index 23a08b33..21eb83b7 100644 --- a/demo/client/which.php +++ b/demo/client/which.php @@ -29,5 +29,3 @@ if (!$resp->faultCode()) { } output("\n"); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/client/wrap.php b/demo/client/wrap.php index d7523494..84ffdb8e 100644 --- a/demo/client/wrap.php +++ b/demo/client/wrap.php @@ -52,5 +52,3 @@ if ($resp->faultCode()) { } output("\n"); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/server/_append.php b/demo/server/_append.php deleted file mode 100644 index da249b30..00000000 --- a/demo/server/_append.php +++ /dev/null @@ -1,7 +0,0 @@ - $getComments_doc, ), )); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/server/proxy.php b/demo/server/proxy.php index f72a8356..d70bf139 100644 --- a/demo/server/proxy.php +++ b/demo/server/proxy.php @@ -89,5 +89,3 @@ $server = new PhpXmlRpc\Server( ), ) ); - -require_once __DIR__ . "/_append.php"; diff --git a/demo/server/server.php b/demo/server/server.php index a40a69de..41c401ce 100644 --- a/demo/server/server.php +++ b/demo/server/server.php @@ -120,5 +120,3 @@ if (isset($_GET['FORCE_AUTH'])) { $s->service(); // That should do all we need! - -require_once __DIR__ . "/_append.php"; diff --git a/demo/vardemo.php b/demo/vardemo.php index 0390f854..ac7e6786 100644 --- a/demo/vardemo.php +++ b/demo/vardemo.php @@ -92,5 +92,3 @@ output("Which was the time in UTC at " . PhpXmlRpc\Helper\Date::iso8601Encode($t output("\n"); output(''); - -require_once __DIR__ . "/client/_append.php"; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a4e4a19a..555c4fc7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,7 +9,6 @@ ./build ./doc - ./extras ./tests ./vendor ./pakefile.php diff --git a/tests/4ClientTest.php b/tests/4ClientTest.php index a2942b4c..ec3ad76c 100644 --- a/tests/4ClientTest.php +++ b/tests/4ClientTest.php @@ -89,7 +89,7 @@ class ClientTest extends PhpXmlRpc_PolyfillTestCase $this->client->port = $server[1]; } $this->client->server = $server[0]; - $this->client->path = $this->args['HTTPURI']; + $this->client->path = str_replace('/demo/server/server.php', '/tests/index.php?demo=server/server.php', $this->args['HTTPURI']); $r = $this->client->send($m, 5, 'http11'); $this->assertEquals(0, $r->faultCode()); diff --git a/tests/5ServerTest.php b/tests/5ServerTest.php index 3db7b8f2..f91b41aa 100644 --- a/tests/5ServerTest.php +++ b/tests/5ServerTest.php @@ -95,18 +95,19 @@ class ServerTest extends PhpXmlRpc_PolyfillTestCase { $this->args = argParser::getArgs(); + $uri = str_replace('/demo/server/server.php', '/tests/index.php?demo=server/server.php', $this->args['HTTPURI']); $server = explode(':', $this->args['HTTPSERVER']); if (count($server) > 1) { - $this->client = new xmlrpc_client($this->args['HTTPURI'], $server[0], $server[1]); + $this->client = new xmlrpc_client($uri, $server[0], $server[1]); } else { - $this->client = new xmlrpc_client($this->args['HTTPURI'], $this->args['HTTPSERVER']); + $this->client = new xmlrpc_client($uri, $this->args['HTTPSERVER']); } $this->client->setDebug($this->args['DEBUG']); $this->client->request_compression = $this->request_compression; $this->client->accepted_compression = $this->accepted_compression; - $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['HTTPURI'] ); + $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . '/' . str_replace('/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['HTTPURI']); if ($this->args['DEBUG'] == 1) ob_start(); diff --git a/tests/6HTTPTest.php b/tests/6HTTPTest.php index e737f81a..6880a0c3 100644 --- a/tests/6HTTPTest.php +++ b/tests/6HTTPTest.php @@ -465,7 +465,7 @@ class HTTPTest extends ServerTest { if ($this->expectHttp2) { $hr = $r->httpResponse(); - $this->assertEquals("2", $hr['protocol_version']); + $this->assertEquals("2", @$hr['protocol_version']); } else { } diff --git a/tests/7DemofilesTest.php b/tests/7DemofilesTest.php index 22334db8..b387ba6f 100644 --- a/tests/7DemofilesTest.php +++ b/tests/7DemofilesTest.php @@ -11,31 +11,31 @@ class DemoFilesTest extends PhpXmlRpc_WebTestCase { $this->args = argParser::getArgs(); - $this->baseUrl = $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/demo/', $this->args['HTTPURI'] ); + $this->baseUrl = $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/tests/index.php', $this->args['HTTPURI'] ); - $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['HTTPURI'] ); + $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/tests/phpunit_coverage.php', $this->args['HTTPURI'] ); } public function testAgeSort() { - $page = $this->request('client/agesort.php'); + $page = $this->request('?demo=client/agesort.php'); } public function testGetStateName() { - $page = $this->request('client/getstatename.php'); - $page = $this->request('client/getstatename.php', 'POST', array('stateno' => '1')); + $page = $this->request('?demo=client/getstatename.php'); + $page = $this->request('?demo=client/getstatename.php', 'POST', array('stateno' => '1')); } public function testIntrospect() { - $page = $this->request('client/introspect.php'); + $page = $this->request('?demo=client/introspect.php'); } public function testMail() { - $page = $this->request('client/mail.php'); - $page = $this->request('client/mail.php', 'POST', array( + $page = $this->request('?demo=client/mail.php'); + $page = $this->request('?demo=client/mail.php', 'POST', array( "mailto" => '', "mailsub" => '', "mailmsg" => '', @@ -47,28 +47,28 @@ class DemoFilesTest extends PhpXmlRpc_WebTestCase public function testParallel() { - $page = $this->request('client/parallel.php'); + $page = $this->request('?demo=client/parallel.php'); } public function testProxy() { - $page = $this->request('client/proxy.php', 'GET', null, true); + $page = $this->request('?demo=client/proxy.php', 'GET', null, true); } public function testWhich() { - $page = $this->request('client/which.php'); + $page = $this->request('?demo=client/which.php'); } public function testWrap() { - $page = $this->request('client/wrap.php'); + $page = $this->request('?demo=client/wrap.php'); } public function testDiscussServer() { /// @todo add a couple of proper xmlrpc calls, too - $page = $this->request('server/discuss.php'); + $page = $this->request('?demo=server/discuss.php'); $this->assertStringContainsString('faultCode', $page); $this->assertRegexp('#10(5|3)#', $page); } @@ -76,7 +76,7 @@ class DemoFilesTest extends PhpXmlRpc_WebTestCase public function testProxyServer() { /// @todo add a couple of proper xmlrpc calls, too - $page = $this->request('server/proxy.php'); + $page = $this->request('?demo=server/proxy.php'); $this->assertStringContainsString('faultCode', $page); $this->assertRegexp('#10(5|3)#', $page); } diff --git a/tests/8DebuggerTest.php b/tests/8DebuggerTest.php index 779ad473..87564715 100644 --- a/tests/8DebuggerTest.php +++ b/tests/8DebuggerTest.php @@ -8,19 +8,19 @@ class DebuggerTest extends PhpXmlRpc_WebTestCase { $this->args = argParser::getArgs(); - $this->baseUrl = $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/debugger/', $this->args['HTTPURI'] ); + $this->baseUrl = $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/tests/index.php', $this->args['HTTPURI'] ); - $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['HTTPURI'] ); + $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/tests/phpunit_coverage.php', $this->args['HTTPURI'] ); } public function testIndex() { - $page = $this->request('index.php'); + $page = $this->request('?debugger=index.php'); } public function testController() { - $page = $this->request('controller.php'); + $page = $this->request('?debugger=controller.php'); } /** @@ -32,6 +32,6 @@ class DebuggerTest extends PhpXmlRpc_WebTestCase */ public function testAction() { - $page = $this->request('action.php'); + $page = $this->request('?debugger=action.php'); } } diff --git a/tests/9ExtraFilesTest.php b/tests/9ExtraFilesTest.php index a88bacea..05df2d69 100644 --- a/tests/9ExtraFilesTest.php +++ b/tests/9ExtraFilesTest.php @@ -12,30 +12,23 @@ class ExtraFilesTest extends PhpXmlRpc_WebTestCase { $this->args = argParser::getArgs(); - $this->baseUrl = $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/extras/', $this->args['HTTPURI'] ); + $this->baseUrl = $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/tests/index.php', $this->args['HTTPURI'] ); - $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['HTTPURI'] ); + $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . str_replace( '/demo/server/server.php', '/tests/phpunit_coverage.php', $this->args['HTTPURI'] ); } - /** - * @todo collect code coverage for this... - */ public function testBenchmark() { - $page = $this->request('benchmark.php'); + $page = $this->request('?extras=benchmark.php'); } - /** - * @todo collect code coverage for this... - */ public function testVerifyCompat() { - $page = $this->request('verify_compat.php'); + $page = $this->request('?extras=verify_compat.php'); } public function testVarDemo() { - $this->baseUrl = str_replace('/extras/', '/demo/', $this->baseUrl); - $page = $this->request('vardemo.php'); + $page = $this->request('?demo=vardemo.php'); } } diff --git a/tests/ci/config/apache_vhost b/tests/ci/config/apache_vhost index 4cb918b1..9852f684 100644 --- a/tests/ci/config/apache_vhost +++ b/tests/ci/config/apache_vhost @@ -20,7 +20,6 @@ # Env vars used by the test code, which we get from the environment SetEnv HTTPSERVER ${HTTPSERVER} - SetEnv TESTMODE true Options FollowSymLinks MultiViews @@ -52,7 +51,6 @@ # Env vars used by the test code, which we get from the environment SetEnv HTTPSERVER ${HTTPSERVER} - SetEnv TESTMODE true Options FollowSymLinks MultiViews diff --git a/tests/index.php b/tests/index.php new file mode 100644 index 00000000..e9796127 --- /dev/null +++ b/tests/index.php @@ -0,0 +1,42 @@ +