diff --git a/tests/PHPCurlClass/Helper.php b/tests/PHPCurlClass/Helper.php index 68ca777..f728f47 100644 --- a/tests/PHPCurlClass/Helper.php +++ b/tests/PHPCurlClass/Helper.php @@ -9,8 +9,11 @@ class Test const TEST_URL = 'http://127.0.0.1:8000/'; const ERROR_URL = 'http://1.2.3.4/'; - public function __construct() + private $testUrl; + + public function __construct($port = null) { + $this->testUrl = $port === null ? self::TEST_URL : $this->getTestUrl($port); $this->curl = new Curl(); $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, false); @@ -21,11 +24,11 @@ class Test $this->curl->setHeader('X-DEBUG-TEST', $test); $request_method = strtolower($request_method); if ($arg1 !== null && $arg2 !== null) { - $this->curl->$request_method(self::TEST_URL, $arg1, $arg2); + $this->curl->$request_method($this->testUrl, $arg1, $arg2); } elseif ($arg1 !== null) { - $this->curl->$request_method(self::TEST_URL, $arg1); + $this->curl->$request_method($this->testUrl, $arg1); } else { - $this->curl->$request_method(self::TEST_URL); + $this->curl->$request_method($this->testUrl); } return $this->curl->response; } diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 9b11cfd..0658d92 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -1133,7 +1133,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testDefaultTimeout() { - $test = new Test(); + $test = new Test('8001'); $test->server('timeout', 'GET', array( 'seconds' => '31', )); @@ -1146,7 +1146,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testTimeoutError() { - $test = new Test(); + $test = new Test('8002'); $test->curl->setTimeout(5); $test->server('timeout', 'GET', array( 'seconds' => '10', @@ -1160,7 +1160,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testTimeout() { - $test = new Test(); + $test = new Test('8003'); $test->curl->verbose(); $test->curl->setTimeout(10); $test->server('timeout_legacy', 'GET', array( @@ -1185,7 +1185,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase public function testError() { - $test = new Test(); + $test = new Test('8004'); $test->curl->get(Test::ERROR_URL); $this->assertTrue($test->curl->error); $this->assertTrue($test->curl->curlError);