From f5456e63644d3d34194912d7c371759807be30ed Mon Sep 17 00:00:00 2001 From: gggeek Date: Sun, 6 Dec 2020 14:56:25 +0000 Subject: [PATCH] tests on php8 --- .travis.yml | 5 ++++ composer.json | 11 +++++---- tests/0CharsetTest.php | 6 +++-- tests/1ParsingBugsTest.php | 8 ++++--- tests/2InvalidHostTest.php | 8 ++++--- tests/3LocalhostTest.php | 22 ++++++++++------- tests/5DemofilesTest.php | 2 +- tests/6DebuggerTest.php | 2 +- tests/7ExtraTest.php | 4 ++-- tests/LocalFileTestCase.php | 10 +++++--- tests/PolyfillTestCase.php | 47 +++++++++++++++++++++++++++++++++++++ 11 files changed, 96 insertions(+), 29 deletions(-) create mode 100644 tests/PolyfillTestCase.php diff --git a/.travis.yml b/.travis.yml index c7fcdd4..4d98740 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,11 @@ language: php # adapt the apache / env setup scripts to accommodate that...) dist: xenial + +global: + # temp workaround to xdebug 3.0.0 bug + - XDEBUG_MODE=coverage + php: #- 5.3 #- 5.4 diff --git a/composer.json b/composer.json index e5082ed..f5db6fd 100644 --- a/composer.json +++ b/composer.json @@ -2,22 +2,23 @@ "name": "phpxmlrpc/phpxmlrpc", "description": "A php library for building xmlrpc clients and servers", "license": "BSD-3-Clause", - "homepage": "http://gggeek.github.io/phpxmlrpc/", + "homepage": "https://gggeek.github.io/phpxmlrpc/", "keywords": [ "xmlrpc", "webservices" ], "require": { "php": ">=5.3.0", "ext-xml": "*" }, "require-dev": { - "phpunit/phpunit": "~4.0 || ~5.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^8.5.12", "phpunit/phpunit-selenium": "*", + "yoast/phpunit-polyfills": "*", "ext-curl": "*", "ext-dom": "*", "ext-mbstring": "*", "ext-xsl": "*", - "indeyets/pake": "~1.99", - "sami/sami": "~3.3", - "docbook/docbook-xsl": "~1.79" + "indeyets/pake": "^1.99", + "sami/sami": "^3.3 || ^4.1", + "docbook/docbook-xsl": "^1.79" }, "suggest": { "ext-curl": "Needed for HTTPS and HTTP 1.1 support, NTLM Auth etc...", diff --git a/tests/0CharsetTest.php b/tests/0CharsetTest.php index 8a62506..c5332ad 100644 --- a/tests/0CharsetTest.php +++ b/tests/0CharsetTest.php @@ -5,6 +5,8 @@ use PhpXmlRpc\Helper\Charset; +include_once __DIR__ . '/PolyfillTestCase.php'; + /** * Test conversion between encodings * @@ -13,7 +15,7 @@ use PhpXmlRpc\Helper\Charset; * chcp 28591 (latin1) * chcp 65001 (utf8) */ -class CharsetTest extends PHPUnit_Framework_TestCase +class CharsetTest extends PhpXmlRpc_PolyfillTestCase { // Consolas font should render these properly protected $runes = "ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ"; @@ -22,7 +24,7 @@ class CharsetTest extends PHPUnit_Framework_TestCase protected $chinese = "我能吞下玻璃而不伤身体。"; protected $latinString; - protected function setUp() + protected function set_up() { // construct a latin string with all chars (except control ones) $this->latinString = "\n\r\t"; diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index d8f5779..4a9f23a 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -7,21 +7,23 @@ include_once __DIR__ . '/../lib/xmlrpcs.inc'; include_once __DIR__ . '/parse_args.php'; +include_once __DIR__ . '/PolyfillTestCase.php'; + /** * Tests involving parsing of xml and handling of xmlrpc values */ -class ParsingBugsTests extends PHPUnit_Framework_TestCase +class ParsingBugsTests extends PhpXmlRpc_PolyfillTestCase { public $args = array(); - protected function setUp() + protected function set_up() { $this->args = argParser::getArgs(); if ($this->args['DEBUG'] == 1) ob_start(); } - protected function tearDown() + protected function tear_down() { if ($this->args['DEBUG'] != 1) return; diff --git a/tests/2InvalidHostTest.php b/tests/2InvalidHostTest.php index 1c81b55..0607c51 100644 --- a/tests/2InvalidHostTest.php +++ b/tests/2InvalidHostTest.php @@ -4,16 +4,18 @@ include_once __DIR__ . '/../lib/xmlrpc.inc'; include_once __DIR__ . '/parse_args.php'; +include_once __DIR__ . '/PolyfillTestCase.php'; + /** * Tests involving requests sent to non-existing servers */ -class InvalidHostTest extends PHPUnit_Framework_TestCase +class InvalidHostTest extends PhpXmlRpc_PolyfillTestCase { /** @var xmlrpc_client $client */ public $client = null; public $args = array(); - public function setUp() + public function set_up() { $this->args = argParser::getArgs(); @@ -24,7 +26,7 @@ class InvalidHostTest extends PHPUnit_Framework_TestCase ob_start(); } - protected function tearDown() + protected function tear_down() { if ($this->args['DEBUG'] != 1) return; diff --git a/tests/3LocalhostTest.php b/tests/3LocalhostTest.php index fc4bb9e..8d35be6 100644 --- a/tests/3LocalhostTest.php +++ b/tests/3LocalhostTest.php @@ -5,11 +5,15 @@ include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc'; include_once __DIR__ . '/parse_args.php'; +include_once __DIR__ . '/PolyfillTestCase.php'; + +use PHPUnit\Framework\TestResult; + /** * 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 +class LocalhostTest extends PhpXmlRpc_PolyfillTestCase { /** @var xmlrpc_client $client */ protected $client = null; @@ -26,7 +30,7 @@ class LocalhostTest extends PHPUnit_Framework_TestCase protected $collectCodeCoverageInformation; protected $coverageScriptUrl; - public static function fail($message = '') + public static function _fail($message = '') { // save in a static var that this particular test has failed // (but only if not called from subclass objects / multitests) @@ -40,18 +44,18 @@ class LocalhostTest extends PHPUnit_Framework_TestCase } } - parent::fail($message); + parent::_fail($message); } /** * Reimplemented to allow us to collect code coverage info from the target server. * Code taken from PHPUnit_Extensions_Selenium2TestCase * - * @param PHPUnit_Framework_TestResult $result - * @return PHPUnit_Framework_TestResult + * @param TestResult $result + * @return TestResult * @throws Exception */ - public function run(PHPUnit_Framework_TestResult $result = NULL) + public function _run(TestResult $result = NULL) { $this->testId = get_class($this) . '__' . $this->getName(); @@ -61,7 +65,7 @@ class LocalhostTest extends PHPUnit_Framework_TestCase $this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation(); - parent::run($result); + parent::_run($result); if ($this->collectCodeCoverageInformation) { $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage( @@ -79,7 +83,7 @@ class LocalhostTest extends PHPUnit_Framework_TestCase return $result; } - public function setUp() + public function set_up() { $this->args = argParser::getArgs(); @@ -100,7 +104,7 @@ class LocalhostTest extends PHPUnit_Framework_TestCase ob_start(); } - protected function tearDown() + protected function tear_down() { if ($this->args['DEBUG'] != 1) return; diff --git a/tests/5DemofilesTest.php b/tests/5DemofilesTest.php index 3cbb5b4..4ee62c8 100644 --- a/tests/5DemofilesTest.php +++ b/tests/5DemofilesTest.php @@ -7,7 +7,7 @@ include_once __DIR__ . '/LocalFileTestCase.php'; */ class DemoFilesTest extends PhpXmlRpc_LocalFileTestCase { - public function setUp() + public function set_up() { $this->args = argParser::getArgs(); diff --git a/tests/6DebuggerTest.php b/tests/6DebuggerTest.php index db0e850..eaacd43 100644 --- a/tests/6DebuggerTest.php +++ b/tests/6DebuggerTest.php @@ -4,7 +4,7 @@ include_once __DIR__ . '/LocalFileTestCase.php'; class DebuggerTest extends PhpXmlRpc_LocalFileTestCase { - public function setUp() + public function set_up() { $this->args = argParser::getArgs(); diff --git a/tests/7ExtraTest.php b/tests/7ExtraTest.php index 14488e8..de7d48f 100644 --- a/tests/7ExtraTest.php +++ b/tests/7ExtraTest.php @@ -7,7 +7,7 @@ include_once __DIR__ . '/LocalFileTestCase.php'; */ class ExtraTest extends PhpXmlRpc_LocalFileTestCase { - public function setUp() + public function set_up() { $this->args = argParser::getArgs(); @@ -20,4 +20,4 @@ class ExtraTest extends PhpXmlRpc_LocalFileTestCase { $page = $this->request('verify_compat.php'); } -} \ No newline at end of file +} diff --git a/tests/LocalFileTestCase.php b/tests/LocalFileTestCase.php index 59818c8..21fda68 100644 --- a/tests/LocalFileTestCase.php +++ b/tests/LocalFileTestCase.php @@ -2,7 +2,11 @@ include_once __DIR__ . '/parse_args.php'; -abstract class PhpXmlRpc_LocalFileTestCase extends PHPUnit_Framework_TestCase +include_once __DIR__ . '/PolyfillTestCase.php'; + +use PHPUnit\Framework\TestResult; + +abstract class PhpXmlRpc_LocalFileTestCase extends PhpXmlRpc_PolyfillTestCase { public $args = array(); @@ -13,7 +17,7 @@ abstract class PhpXmlRpc_LocalFileTestCase extends PHPUnit_Framework_TestCase protected $collectCodeCoverageInformation; protected $coverageScriptUrl; - public function run(PHPUnit_Framework_TestResult $result = NULL) + public function _run(TestResult $result = NULL) { $this->testId = get_class($this) . '__' . $this->getName(); @@ -23,7 +27,7 @@ abstract class PhpXmlRpc_LocalFileTestCase extends PHPUnit_Framework_TestCase $this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation(); - parent::run($result); + parent::_run($result); if ($this->collectCodeCoverageInformation) { $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage( diff --git a/tests/PolyfillTestCase.php b/tests/PolyfillTestCase.php new file mode 100644 index 0000000..5dc8961 --- /dev/null +++ b/tests/PolyfillTestCase.php @@ -0,0 +1,47 @@ +_run($result); + } + + public static function fail($message = '') { + static::_fail($message); + self::fail($message); + } + } +} else { + abstract class PhpXmlRpc_PolyfillTestCase extends TestCase + { + public function _run(TestResult $result = null) { + return parent::run($result); + } + + public static function _fail() {} + + public function run(TestResult $result = null): TestResult { + return $this->_run($result); + } + + public static function fail(string $message = ''): void { + static::_fail($message); + parent::fail($message); + } + } +} -- 2.43.0