diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d4e5458b45..bee0ed77fe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ diff --git a/test/Client/CommonHttpTests.php b/test/Client/CommonHttpTests.php index ef3db7485f..d5a8c8a388 100644 --- a/test/Client/CommonHttpTests.php +++ b/test/Client/CommonHttpTests.php @@ -844,9 +844,7 @@ public function testUploadLocalDetectMime() ); } - $file = dirname(realpath(__FILE__)) - . DIRECTORY_SEPARATOR . '_files' - . DIRECTORY_SEPARATOR . 'staticFile.jpg'; + $file = __DIR__ . '/_files/staticFile.jpg'; $this->client->setUri($this->baseuri . 'testUploads.php'); $this->client->setFileUpload($file, 'uploadfile'); @@ -884,7 +882,7 @@ public function testStaticLargeFileDownload() $this->client->setUri($this->baseuri . 'staticFile.jpg'); $got = $this->client->send()->getBody(); - $expected = $this->_getTestFileContents('staticFile.jpg'); + $expected = $this->getTestFileContents('staticFile.jpg'); $this->assertEquals($expected, $got, 'Downloaded file does not seem to match!'); } @@ -934,7 +932,7 @@ public function testZF4238FalseLinesInResponse() $this->client->setUri($this->baseuri . 'ZF4238-zerolineresponse.txt'); $got = $this->client->send()->getBody(); - $expected = $this->_getTestFileContents('ZF4238-zerolineresponse.txt'); + $expected = $this->getTestFileContents('ZF4238-zerolineresponse.txt'); $this->assertEquals($expected, $got); } @@ -957,7 +955,7 @@ public function testStreamResponse() $streamRead = stream_get_contents($response->getStream()); $fileRead = file_get_contents($streamName); - $expected = $this->_getTestFileContents('staticFile.jpg'); + $expected = $this->getTestFileContents('staticFile.jpg'); $this->assertEquals($expected, $streamRead, 'Downloaded stream does not seem to match!'); $this->assertEquals($expected, $fileRead, 'Downloaded file does not seem to match!'); @@ -981,7 +979,7 @@ public function testStreamResponseBody() $body = $response->getBody(); - $expected = $this->_getTestFileContents('staticFile.jpg'); + $expected = $this->getTestFileContents('staticFile.jpg'); $this->assertEquals($expected, $body, 'Downloaded stream does not seem to match!'); } @@ -1005,7 +1003,7 @@ public function testStreamResponseNamed() $streamRead = stream_get_contents($response->getStream()); $fileRead = file_get_contents($outfile); - $expected = $this->_getTestFileContents('staticFile.jpg'); + $expected = $this->getTestFileContents('staticFile.jpg'); $this->assertEquals($expected, $streamRead, 'Downloaded stream does not seem to match!'); $this->assertEquals($expected, $fileRead, 'Downloaded file does not seem to match!'); @@ -1017,17 +1015,12 @@ public function testStreamRequest() $this->markTestSkipped('Current adapter does not support streaming'); return; } - $data = fopen( - dirname(realpath(__FILE__)) - . DIRECTORY_SEPARATOR . '_files' - . DIRECTORY_SEPARATOR . 'staticFile.jpg', - 'r' - ); + $data = fopen(__DIR__ . '/_files/staticFile.jpg', 'r'); $this->client->setRawBody($data); $this->client->setEncType('image/jpeg'); $this->client->setMethod('PUT'); $res = $this->client->send(); - $expected = $this->_getTestFileContents('staticFile.jpg'); + $expected = $this->getTestFileContents('staticFile.jpg'); $this->assertEquals($expected, $res->getBody(), 'Response body does not contain the expected data'); } @@ -1039,11 +1032,7 @@ public function testStreamRequest() public function testZF9404DoubleContentLengthHeader() { $this->client->setUri($this->baseuri . 'ZF9404-doubleContentLength.php'); - $expect = filesize( - dirname(realpath(__FILE__)) - . DIRECTORY_SEPARATOR . '_files' - . DIRECTORY_SEPARATOR . 'ZF9404-doubleContentLength.php' - ); + $expect = filesize(__DIR__ . '/_files/ZF9404-doubleContentLength.php'); $response = $this->client->send(); if (! $response->isSuccess()) { @@ -1107,15 +1096,9 @@ public function testUsesProvidedArgSeparator() * @param string $file * @return string */ - // @codingStandardsIgnoreStart - protected function _getTestFileContents($file) + private function getTestFileContents($file) { - // @codingStandardsIgnoreEnd - return file_get_contents( - dirname(realpath(__FILE__)) - . DIRECTORY_SEPARATOR . '_files' - . DIRECTORY_SEPARATOR . $file - ); + return file_get_contents(__DIR__ . '/_files/' . $file); } /** diff --git a/test/Client/CurlTest.php b/test/Client/CurlTest.php index 6dc81a3fc2..78da1df3c5 100644 --- a/test/Client/CurlTest.php +++ b/test/Client/CurlTest.php @@ -221,11 +221,7 @@ public function testPutFileContentWithHttpClient() { // Method 1: Using the binary string of a file to PUT $this->client->setUri($this->baseuri . 'testRawPostData.php'); - $putFileContents = file_get_contents( - dirname(realpath(__FILE__)) - . DIRECTORY_SEPARATOR . '_files' - . DIRECTORY_SEPARATOR . 'staticFile.jpg' - ); + $putFileContents = file_get_contents(__DIR__ . '/_files/staticFile.jpg'); $this->client->setRawBody($putFileContents); $this->client->setMethod('PUT'); @@ -240,16 +236,10 @@ public function testPutFileContentWithHttpClient() public function testPutFileHandleWithHttpClient() { $this->client->setUri($this->baseuri . 'testRawPostData.php'); - $putFileContents = file_get_contents( - dirname(realpath(__FILE__)) - . DIRECTORY_SEPARATOR . '_files' - . DIRECTORY_SEPARATOR . 'staticFile.jpg' - ); + $putFileContents = file_get_contents(__DIR__ . '/_files/staticFile.jpg'); // Method 2: Using a File-Handle to the file to PUT the data - $putFilePath = dirname(realpath(__FILE__)) - . DIRECTORY_SEPARATOR . '_files' - . DIRECTORY_SEPARATOR . 'staticFile.jpg'; + $putFilePath = __DIR__ . '/_files/staticFile.jpg'; $putFileHandle = fopen($putFilePath, 'r'); $putFileSize = filesize($putFilePath); diff --git a/test/Client/ProxyAdapterTest.php b/test/Client/ProxyAdapterTest.php index fe2fe53d4e..439814b096 100644 --- a/test/Client/ProxyAdapterTest.php +++ b/test/Client/ProxyAdapterTest.php @@ -24,14 +24,12 @@ */ class ProxyAdapterTest extends SocketTest { + /** @var string */ protected $host; + + /** @var int */ protected $port; - /** - * Configuration array - * - * @var array - */ protected function setUp() { if (getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') @@ -46,32 +44,19 @@ protected function setUp() $this->host = $host; $port = (int) $port; - if ($port == 0) { + if ($port === 0) { $port = 8080; - } else { - if (($port < 1 || $port > 65535)) { - $this->markTestSkipped(sprintf( - '%s is not a valid proxy port number. Should be between 1 and 65535.', - $port - )); - } + } elseif ($port < 1 || $port > 65535) { + $this->markTestSkipped(sprintf( + '%s is not a valid proxy port number. Should be between 1 and 65535.', + $port + )); } $this->port = $port; - $user = ''; - $pass = ''; - if (getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') - && getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') - ) { - $user = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER'); - } - - if (getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') - && getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') - ) { - $pass = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS'); - } + $user = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') ?: ''; + $pass = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') ?: ''; $this->config = [ 'adapter' => Proxy::class, diff --git a/test/bootstrap.php b/test/bootstrap.php deleted file mode 100644 index a7cf020d42..0000000000 --- a/test/bootstrap.php +++ /dev/null @@ -1,34 +0,0 @@ -