test cleanups
authorgggeek <giunta.gaetano@gmail.com>
Wed, 16 Dec 2020 10:28:45 +0000 (10:28 +0000)
committergggeek <giunta.gaetano@gmail.com>
Wed, 16 Dec 2020 10:28:45 +0000 (10:28 +0000)
tests/1ParsingBugsTest.php
tests/2InvalidHostTest.php
tests/3LocalhostTest.php
tests/LocalFileTestCase.php
tests/PolyfillTestCase.php
tests/parse_args.php

index 09d8b2f..3fa7b8e 100644 (file)
@@ -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;
         }
     }
index 18c8f6c..c7419ec 100644 (file)
@@ -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;
         }
     }
index d513b09..2ec0150 100644 (file)
@@ -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;
         }
     }
index 9cc660f..4062812 100644 (file)
@@ -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;
     }
-
 }
index 14e42c9..24957fa 100644 (file)
@@ -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', '<')) {
index 6fdef4b..d4e6624 100644 (file)
@@ -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
 {