From: gggeek Date: Wed, 16 Dec 2020 10:28:45 +0000 (+0000) Subject: test cleanups X-Git-Tag: plcapi-7.1-0~3^2~111 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=9354db3aa7572bf371a7ef6dfe37eebc4e8eaf33;p=plcapi.git test cleanups --- diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index 09d8b2f..3fa7b8e 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -9,6 +9,8 @@ include_once __DIR__ . '/parse_args.php'; include_once __DIR__ . '/PolyfillTestCase.php'; +use PHPUnit\Runner\BaseTestRunner; + /** * Tests involving parsing of xml and handling of xmlrpc values */ @@ -29,8 +31,8 @@ class ParsingBugsTests extends PhpXmlRpc_PolyfillTestCase return; $out = ob_get_clean(); $status = $this->getStatus(); - if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR - || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { + if ($status == BaseTestRunner::STATUS_ERROR + || $status == BaseTestRunner::STATUS_FAILURE) { echo $out; } } diff --git a/tests/2InvalidHostTest.php b/tests/2InvalidHostTest.php index 18c8f6c..c7419ec 100644 --- a/tests/2InvalidHostTest.php +++ b/tests/2InvalidHostTest.php @@ -6,6 +6,8 @@ include_once __DIR__ . '/parse_args.php'; include_once __DIR__ . '/PolyfillTestCase.php'; +use PHPUnit\Runner\BaseTestRunner; + /** * Tests involving requests sent to non-existing servers */ @@ -32,8 +34,8 @@ class InvalidHostTest extends PhpXmlRpc_PolyfillTestCase return; $out = ob_get_clean(); $status = $this->getStatus(); - if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR - || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { + if ($status == BaseTestRunner::STATUS_ERROR + || $status == BaseTestRunner::STATUS_FAILURE) { echo $out; } } diff --git a/tests/3LocalhostTest.php b/tests/3LocalhostTest.php index d513b09..2ec0150 100644 --- a/tests/3LocalhostTest.php +++ b/tests/3LocalhostTest.php @@ -7,7 +7,9 @@ include_once __DIR__ . '/parse_args.php'; include_once __DIR__ . '/PolyfillTestCase.php'; +use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage; use PHPUnit\Framework\TestResult; +use PHPUnit\Runner\BaseTestRunner; /** * Tests which involve interaction between the client and the server. @@ -31,7 +33,7 @@ class LocalhostTest extends PhpXmlRpc_PolyfillTestCase protected $coverageScriptUrl; /** - * @todo instead of overriding run via _fail, implement PHPUnit_Framework_TestListener - IFF there is such an API portable across PHPUnit 5 to 9... + * @todo instead of overriding fail via _fail, implement Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation */ public static function _fail($message = '') { @@ -58,7 +60,7 @@ class LocalhostTest extends PhpXmlRpc_PolyfillTestCase * @return TestResult * @throws Exception * - * @todo instead of overriding run via _run, subclass PHPUnit_Extensions_TestDecorator - IFF there is such an API portable across PHPUnit 5 to 9... + * @todo instead of overriding run via _run, try to achieve this by implementing Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation */ public function _run($result = NULL) { @@ -73,7 +75,7 @@ class LocalhostTest extends PhpXmlRpc_PolyfillTestCase parent::_run($result); if ($this->collectCodeCoverageInformation) { - $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage( + $coverage = new RemoteCoverage( $this->coverageScriptUrl, $this->testId ); @@ -115,8 +117,8 @@ class LocalhostTest extends PhpXmlRpc_PolyfillTestCase return; $out = ob_get_clean(); $status = $this->getStatus(); - if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR - || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) { + if ($status == BaseTestRunner::STATUS_ERROR + || $status == BaseTestRunner::STATUS_FAILURE) { echo $out; } } diff --git a/tests/LocalFileTestCase.php b/tests/LocalFileTestCase.php index 9cc660f..4062812 100644 --- a/tests/LocalFileTestCase.php +++ b/tests/LocalFileTestCase.php @@ -4,6 +4,11 @@ include_once __DIR__ . '/parse_args.php'; include_once __DIR__ . '/PolyfillTestCase.php'; +use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage; + +/** + * @todo rename + */ abstract class PhpXmlRpc_LocalFileTestCase extends PhpXmlRpc_PolyfillTestCase { public $args = array(); @@ -19,7 +24,7 @@ abstract class PhpXmlRpc_LocalFileTestCase extends PhpXmlRpc_PolyfillTestCase * Reimplemented to allow us to collect code coverage info for the target php files executed via an http request. * Code taken from PHPUnit_Extensions_Selenium2TestCase * - * @todo instead of overriding run via _run, subclass PHPUnit_Extensions_TestDecorator - IFF there is such an API portable across PHPUnit 5 to 9... + * @todo instead of overriding run via _run, try to achieve this by implementing Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation */ public function _run($result = NULL) { @@ -34,7 +39,7 @@ abstract class PhpXmlRpc_LocalFileTestCase extends PhpXmlRpc_PolyfillTestCase parent::_run($result); if ($this->collectCodeCoverageInformation) { - $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage( + $coverage = new RemoteCoverage( $this->coverageScriptUrl, $this->testId ); @@ -84,5 +89,4 @@ abstract class PhpXmlRpc_LocalFileTestCase extends PhpXmlRpc_PolyfillTestCase return $page; } - } diff --git a/tests/PolyfillTestCase.php b/tests/PolyfillTestCase.php index 14e42c9..24957fa 100644 --- a/tests/PolyfillTestCase.php +++ b/tests/PolyfillTestCase.php @@ -2,10 +2,16 @@ use PHPUnit\Runner\Version as PHPUnit_Version; -/// @todo we should do the opposite - write test code to the 'new' phpunit API, and alias it to the 'old' class name -/// when old classes are present... -if (!class_exists('PHPUnit_Extensions_SeleniumCommon_RemoteCoverage')) { - class PHPUnit_Extensions_SeleniumCommon_RemoteCoverage extends PHPUnit\Extensions\SeleniumCommon\RemoteCoverage {} +if ( class_exists( 'PHPUnit_Extensions_SeleniumCommon_RemoteCoverage' ) === true + && class_exists( 'PHPUnit\Extensions\SeleniumCommon\RemoteCoverage' ) === false +) { + class_alias( 'PHPUnit_Extensions_SeleniumCommon_RemoteCoverage', 'PHPUnit\Extensions\SeleniumCommon\RemoteCoverage' ); +} + +if ( class_exists( 'PHPUnit_Runner_BaseTestRunner' ) === true + && class_exists( 'PHPUnit\Runner\BaseTestRunner' ) === false +) { + class_alias( 'PHPUnit_Runner_BaseTestRunner', 'PHPUnit\Runner\BaseTestRunner' ); } if (class_exists(PHPUnit_Version::class) === false || version_compare(PHPUnit_Version::id(), '8.0.0', '<')) { diff --git a/tests/parse_args.php b/tests/parse_args.php index 6fdef4b..d4e6624 100644 --- a/tests/parse_args.php +++ b/tests/parse_args.php @@ -15,6 +15,8 @@ * * @copyright (C) 2007-2020 G. Giunta * @license code licensed under the BSD License: see file license.txt + * + * @todo rename both the class and the file. PhpXmlRpc_TestArgParser ? **/ class argParser {