improve code coverage for demo files
authorgggeek <giunta.gaetano@gmail.com>
Sun, 13 Dec 2020 21:55:58 +0000 (21:55 +0000)
committergggeek <giunta.gaetano@gmail.com>
Sun, 13 Dec 2020 21:55:58 +0000 (21:55 +0000)
16 files changed:
.travis.yml
demo/client/_append.php [new file with mode: 0644]
demo/client/_prepend.php [moved from demo/client/_bootstrap.php with 59% similarity]
demo/client/agesort.php
demo/client/getstatename.php
demo/client/introspect.php
demo/client/mail.php
demo/client/proxy.php
demo/client/which.php
demo/client/wrap.php
demo/server/_append.php [new file with mode: 0644]
demo/server/_bootstrap.php [deleted file]
demo/server/_prepend.php [new file with mode: 0644]
demo/server/discuss.php
demo/server/proxy.php
demo/server/server.php

index 722eeba..9d1f3c0 100644 (file)
@@ -72,7 +72,7 @@ after_failure:
 
 after_script:
   # Upload code-coverage to Scrutinizer
-  - if [ -f coverage.clover ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover && echo 'code coverage uploaded to Scrutinizer'; fi
+  - if [ -f coverage.clover ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
   # Upload code-coverage CodeClimate - disabled as it does not support php 8 atm
   #- if [ -f coverage.clover ]; then CODECLIMATE_REPO_TOKEN=7fa6ee01e345090e059e5e42f3bfbcc8692feb8340396382dd76390a3019ac13 ./vendor/bin/test-reporter --coverage-report=coverage.clover; fi
 
diff --git a/demo/client/_append.php b/demo/client/_append.php
new file mode 100644 (file)
index 0000000..da249b3
--- /dev/null
@@ -0,0 +1,7 @@
+<?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!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+    include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";
+}
similarity index 59%
rename from demo/client/_bootstrap.php
rename to demo/client/_prepend.php
index 0645d3a..e2a480f 100644 (file)
@@ -23,3 +23,14 @@ if (isset($_SERVER['HTTPSERVER'])) {
 } else {
     define('XMLRPCSERVER', 'http://phpxmlrpc.sourceforge.net/server.php');
 }
+
+// Out-of-band information: let the client manipulate the page operations.
+// We do this to help the testsuite script: do not reproduce in production!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+    $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
+    if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
+        mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
+    }
+
+    include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
+}
index 48011b3..9ad397f 100644 (file)
@@ -1,4 +1,4 @@
-<?php require_once __DIR__ . "/_bootstrap.php"; ?><html lang="en">
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Agesort demo</title></head>
 <body>
 <h1>Agesort demo</h1>
@@ -62,4 +62,4 @@ if (!$resp->faultCode()) {
 
 ?>
 </body>
-</html>
+</html><?php require_once __DIR__ . "/_append.php"; ?>
index 304bf25..a83d907 100644 (file)
@@ -1,4 +1,4 @@
-<?php require_once __DIR__ . "/_bootstrap.php"; ?><html lang="en">
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Getstatename demo</title></head>
 <body>
 <h1>Getstatename demo</h1>
@@ -39,4 +39,4 @@ print "<form action=\"getstatename.php\" method=\"POST\">
 
 ?>
 </body>
-</html>
+</html><?php require_once __DIR__ . "/_append.php"; ?>
index 57df918..f8bb6b0 100644 (file)
@@ -1,4 +1,4 @@
-<?php require_once __DIR__ . "/_bootstrap.php"; ?><html lang="en">
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Introspect demo</title></head>
 <body>
 <h1>Introspect demo</h1>
@@ -81,4 +81,4 @@ if ($resp->faultCode()) {
 }
 ?>
 </body>
-</html>
+</html><?php require_once __DIR__ . "/_append.php"; ?>
index 32a4a1f..dfaba04 100644 (file)
@@ -1,4 +1,4 @@
-<?php require_once __DIR__ . "/_bootstrap.php"; ?><html lang="en">
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Mail demo</title></head>
 <body>
 <h1>Mail demo</h1>
@@ -57,4 +57,4 @@ if (isset($_POST["mailto"]) && $_POST["mailto"]) {
     <input type="Submit" value="Send"/>
 </form>
 </body>
-</html>
+</html><?php require_once __DIR__ . "/_append.php"; ?>
index 88be2f1..cdbddc2 100644 (file)
@@ -1,4 +1,4 @@
-<?php require_once __DIR__ . "/_bootstrap.php"; ?><html lang="en">
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Proxy demo</title></head>
 <body>
 <h1>proxy demo</h1>
@@ -55,3 +55,5 @@ $proxy = new PhpXmlRpcProxy(new \PhpXmlRpc\Client(XMLRPCSERVER));
 $stateName = $proxy->getStateName($stateNo);
 
 echo "State $stateNo is ".htmlspecialchars($stateName);
+
+require_once __DIR__ . "/_append.php";
index 6664e2f..1c1ba36 100644 (file)
@@ -1,4 +1,4 @@
-<?php require_once __DIR__ . "/_bootstrap.php"; ?><html lang="en">
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Which toolkit demo</title></head>
 <body>
 <h1>Which toolkit demo</h1>
@@ -26,4 +26,4 @@ if (!$resp->faultCode()) {
 }
 ?>
 </body>
-</html>
+</html><?php require_once __DIR__ . "/_append.php"; ?>
index 88d6a8d..4e3db40 100644 (file)
@@ -1,4 +1,4 @@
-<?php require_once __DIR__ . "/_bootstrap.php"; ?><html lang="en">
+<?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
 <head><title>xmlrpc - Webservice wrappper demo</title></head>
 <body>
 <h1>Webservice wrappper demo</h1>
@@ -49,4 +49,4 @@ if ($resp->faultCode()) {
 }
 ?>
 </body>
-</html>
+</html><?php require_once __DIR__ . "/_append.php"; ?>
diff --git a/demo/server/_append.php b/demo/server/_append.php
new file mode 100644 (file)
index 0000000..da249b3
--- /dev/null
@@ -0,0 +1,7 @@
+<?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!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+    include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";
+}
diff --git a/demo/server/_bootstrap.php b/demo/server/_bootstrap.php
deleted file mode 100644 (file)
index b16296e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-/**
- * Hackish code used to make the demos both viewable as source, runnable, and viewable as html
- */
-
-// Make errors visible
-ini_set('display_errors', true);
-error_reporting(E_ALL);
-
-if (isset($_GET['showSource']) && $_GET['showSource']) {
-    $file = debug_backtrace()[0]['file'];
-    highlight_file($file);
-    die();
-}
-
-// Use the custom class autoloader. These two lines not needed when the phpxmlrpc library is installed using Composer
-include_once __DIR__ . '/../../src/Autoloader.php';
-PhpXmlRpc\Autoloader::register();
diff --git a/demo/server/_prepend.php b/demo/server/_prepend.php
new file mode 100644 (file)
index 0000000..3963a32
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Hackish code used to make the demos both viewable as source, runnable, and viewable as html
+ */
+
+// Make errors visible
+ini_set('display_errors', true);
+error_reporting(E_ALL);
+
+if (isset($_GET['showSource']) && $_GET['showSource']) {
+    $file = debug_backtrace()[0]['file'];
+    highlight_file($file);
+    die();
+}
+
+// Use the custom class autoloader. These two lines not needed when the phpxmlrpc library is installed using Composer
+include_once __DIR__ . '/../../src/Autoloader.php';
+PhpXmlRpc\Autoloader::register();
+
+// Out-of-band information: let the client manipulate the server operations.
+// We do this to help the testsuite script: do not reproduce in production!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+    $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
+    if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
+        mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
+    }
+
+    include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
+}
index d187695..ca5dd7d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-require_once __DIR__ . "/_bootstrap.php";
+require_once __DIR__ . "/_prepend.php";
 
 use PhpXmlRpc\Value;
 
@@ -100,3 +100,5 @@ $srv = new PhpXmlRpc\Server(array(
         "docstring" => $getComments_doc,
     ),
 ));
+
+require_once __DIR__ . "/_append.php";
index 812584f..c501d60 100644 (file)
@@ -9,7 +9,7 @@
  * @license code licensed under the BSD License: see file license.txt
  */
 
-require_once __DIR__ . "/_bootstrap.php";
+require_once __DIR__ . "/_prepend.php";
 
 /**
  * Forward an xmlrpc request to another server, and return to client the response received.
@@ -87,3 +87,5 @@ $server = new PhpXmlRpc\Server(
         ),
     )
 );
+
+require_once __DIR__ . "/_append.php";
index 2c48b73..7f60ac1 100644 (file)
@@ -9,18 +9,7 @@
  * Please do not copy this file verbatim into your production server.
  **/
 
-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!
-if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
-    $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
-    if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
-        mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
-    }
-
-    include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
-}
+require_once __DIR__ . "/_prepend.php";
 
 use PhpXmlRpc\Value;
 
@@ -987,8 +976,4 @@ if (isset($_GET['FORCE_AUTH'])) {
 $s->service();
 // That should do all we need!
 
-// Out-of-band information: let the client manipulate the server operations.
-// We do this to help the testsuite script: do not reproduce in production!
-if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
-    include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";
-}
+require_once __DIR__ . "/_append.php";