test cleanups
[plcapi.git] / tests / 3LocalhostTest.php
index 8d35be6..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.
@@ -30,6 +32,9 @@ class LocalhostTest extends PhpXmlRpc_PolyfillTestCase
     protected $collectCodeCoverageInformation;
     protected $coverageScriptUrl;
 
+    /**
+     * @todo instead of overriding fail via _fail, implement Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation
+     */
     public static function _fail($message = '')
     {
         // save in a static var that this particular test has failed
@@ -54,8 +59,10 @@ class LocalhostTest extends PhpXmlRpc_PolyfillTestCase
      * @param TestResult $result
      * @return TestResult
      * @throws Exception
+     *
+     * @todo instead of overriding run via _run, try to achieve this by implementing Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation
      */
-    public function _run(TestResult $result = NULL)
+    public function _run($result = NULL)
     {
         $this->testId = get_class($this) . '__' . $this->getName();
 
@@ -68,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
             );
@@ -87,18 +94,18 @@ class LocalhostTest extends PhpXmlRpc_PolyfillTestCase
     {
         $this->args = argParser::getArgs();
 
-        $server = explode(':', $this->args['LOCALSERVER']);
+        $server = explode(':', $this->args['HTTPSERVER']);
         if (count($server) > 1) {
-            $this->client = new xmlrpc_client($this->args['URI'], $server[0], $server[1]);
+            $this->client = new xmlrpc_client($this->args['HTTPURI'], $server[0], $server[1]);
         } else {
-            $this->client = new xmlrpc_client($this->args['URI'], $this->args['LOCALSERVER']);
+            $this->client = new xmlrpc_client($this->args['HTTPURI'], $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['LOCALSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['URI'] );
+        $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();
@@ -110,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;
         }
     }
@@ -969,7 +976,7 @@ And turned it into nylon';
             new xmlrpcval('hello world', 'string'),
         ));
         $r = $this->send($m, 0, true);
-        $this->assertContains('hello world', $r->raw_data);
+        $this->assertStringContainsString('hello world', $r->raw_data);
     }
 
     public function testSendTwiceSameMsg()