Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit cd002e8

Browse files
committed
Merge branch 'improvement/195' into develop
Forward port #195
2 parents 2cf317a + 81737e0 commit cd002e8

File tree

5 files changed

+26
-102
lines changed

5 files changed

+26
-102
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4-
bootstrap="./test/bootstrap.php"
4+
bootstrap="vendor/autoload.php"
55
colors="true">
66
<testsuites>
77
<testsuite name="zend-http Test Suite">

test/Client/CommonHttpTests.php

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -844,9 +844,7 @@ public function testUploadLocalDetectMime()
844844
);
845845
}
846846

847-
$file = dirname(realpath(__FILE__))
848-
. DIRECTORY_SEPARATOR . '_files'
849-
. DIRECTORY_SEPARATOR . 'staticFile.jpg';
847+
$file = __DIR__ . '/_files/staticFile.jpg';
850848

851849
$this->client->setUri($this->baseuri . 'testUploads.php');
852850
$this->client->setFileUpload($file, 'uploadfile');
@@ -884,7 +882,7 @@ public function testStaticLargeFileDownload()
884882
$this->client->setUri($this->baseuri . 'staticFile.jpg');
885883

886884
$got = $this->client->send()->getBody();
887-
$expected = $this->_getTestFileContents('staticFile.jpg');
885+
$expected = $this->getTestFileContents('staticFile.jpg');
888886

889887
$this->assertEquals($expected, $got, 'Downloaded file does not seem to match!');
890888
}
@@ -934,7 +932,7 @@ public function testZF4238FalseLinesInResponse()
934932
$this->client->setUri($this->baseuri . 'ZF4238-zerolineresponse.txt');
935933

936934
$got = $this->client->send()->getBody();
937-
$expected = $this->_getTestFileContents('ZF4238-zerolineresponse.txt');
935+
$expected = $this->getTestFileContents('ZF4238-zerolineresponse.txt');
938936
$this->assertEquals($expected, $got);
939937
}
940938

@@ -957,7 +955,7 @@ public function testStreamResponse()
957955
$streamRead = stream_get_contents($response->getStream());
958956
$fileRead = file_get_contents($streamName);
959957

960-
$expected = $this->_getTestFileContents('staticFile.jpg');
958+
$expected = $this->getTestFileContents('staticFile.jpg');
961959

962960
$this->assertEquals($expected, $streamRead, 'Downloaded stream does not seem to match!');
963961
$this->assertEquals($expected, $fileRead, 'Downloaded file does not seem to match!');
@@ -981,7 +979,7 @@ public function testStreamResponseBody()
981979

982980
$body = $response->getBody();
983981

984-
$expected = $this->_getTestFileContents('staticFile.jpg');
982+
$expected = $this->getTestFileContents('staticFile.jpg');
985983
$this->assertEquals($expected, $body, 'Downloaded stream does not seem to match!');
986984
}
987985

@@ -1005,7 +1003,7 @@ public function testStreamResponseNamed()
10051003
$streamRead = stream_get_contents($response->getStream());
10061004
$fileRead = file_get_contents($outfile);
10071005

1008-
$expected = $this->_getTestFileContents('staticFile.jpg');
1006+
$expected = $this->getTestFileContents('staticFile.jpg');
10091007

10101008
$this->assertEquals($expected, $streamRead, 'Downloaded stream does not seem to match!');
10111009
$this->assertEquals($expected, $fileRead, 'Downloaded file does not seem to match!');
@@ -1017,17 +1015,12 @@ public function testStreamRequest()
10171015
$this->markTestSkipped('Current adapter does not support streaming');
10181016
return;
10191017
}
1020-
$data = fopen(
1021-
dirname(realpath(__FILE__))
1022-
. DIRECTORY_SEPARATOR . '_files'
1023-
. DIRECTORY_SEPARATOR . 'staticFile.jpg',
1024-
'r'
1025-
);
1018+
$data = fopen(__DIR__ . '/_files/staticFile.jpg', 'r');
10261019
$this->client->setRawBody($data);
10271020
$this->client->setEncType('image/jpeg');
10281021
$this->client->setMethod('PUT');
10291022
$res = $this->client->send();
1030-
$expected = $this->_getTestFileContents('staticFile.jpg');
1023+
$expected = $this->getTestFileContents('staticFile.jpg');
10311024
$this->assertEquals($expected, $res->getBody(), 'Response body does not contain the expected data');
10321025
}
10331026

@@ -1039,11 +1032,7 @@ public function testStreamRequest()
10391032
public function testZF9404DoubleContentLengthHeader()
10401033
{
10411034
$this->client->setUri($this->baseuri . 'ZF9404-doubleContentLength.php');
1042-
$expect = filesize(
1043-
dirname(realpath(__FILE__))
1044-
. DIRECTORY_SEPARATOR . '_files'
1045-
. DIRECTORY_SEPARATOR . 'ZF9404-doubleContentLength.php'
1046-
);
1035+
$expect = filesize(__DIR__ . '/_files/ZF9404-doubleContentLength.php');
10471036

10481037
$response = $this->client->send();
10491038
if (! $response->isSuccess()) {
@@ -1107,15 +1096,9 @@ public function testUsesProvidedArgSeparator()
11071096
* @param string $file
11081097
* @return string
11091098
*/
1110-
// @codingStandardsIgnoreStart
1111-
protected function _getTestFileContents($file)
1099+
private function getTestFileContents($file)
11121100
{
1113-
// @codingStandardsIgnoreEnd
1114-
return file_get_contents(
1115-
dirname(realpath(__FILE__))
1116-
. DIRECTORY_SEPARATOR . '_files'
1117-
. DIRECTORY_SEPARATOR . $file
1118-
);
1101+
return file_get_contents(__DIR__ . '/_files/' . $file);
11191102
}
11201103

11211104
/**

test/Client/CurlTest.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ public function testPutFileContentWithHttpClient()
221221
{
222222
// Method 1: Using the binary string of a file to PUT
223223
$this->client->setUri($this->baseuri . 'testRawPostData.php');
224-
$putFileContents = file_get_contents(
225-
dirname(realpath(__FILE__))
226-
. DIRECTORY_SEPARATOR . '_files'
227-
. DIRECTORY_SEPARATOR . 'staticFile.jpg'
228-
);
224+
$putFileContents = file_get_contents(__DIR__ . '/_files/staticFile.jpg');
229225

230226
$this->client->setRawBody($putFileContents);
231227
$this->client->setMethod('PUT');
@@ -240,16 +236,10 @@ public function testPutFileContentWithHttpClient()
240236
public function testPutFileHandleWithHttpClient()
241237
{
242238
$this->client->setUri($this->baseuri . 'testRawPostData.php');
243-
$putFileContents = file_get_contents(
244-
dirname(realpath(__FILE__))
245-
. DIRECTORY_SEPARATOR . '_files'
246-
. DIRECTORY_SEPARATOR . 'staticFile.jpg'
247-
);
239+
$putFileContents = file_get_contents(__DIR__ . '/_files/staticFile.jpg');
248240

249241
// Method 2: Using a File-Handle to the file to PUT the data
250-
$putFilePath = dirname(realpath(__FILE__))
251-
. DIRECTORY_SEPARATOR . '_files'
252-
. DIRECTORY_SEPARATOR . 'staticFile.jpg';
242+
$putFilePath = __DIR__ . '/_files/staticFile.jpg';
253243
$putFileHandle = fopen($putFilePath, 'r');
254244
$putFileSize = filesize($putFilePath);
255245

test/Client/ProxyAdapterTest.php

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
*/
2525
class ProxyAdapterTest extends SocketTest
2626
{
27+
/** @var string */
2728
protected $host;
29+
30+
/** @var int */
2831
protected $port;
2932

30-
/**
31-
* Configuration array
32-
*
33-
* @var array
34-
*/
3533
protected function setUp()
3634
{
3735
if (getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY')
@@ -46,32 +44,19 @@ protected function setUp()
4644
$this->host = $host;
4745

4846
$port = (int) $port;
49-
if ($port == 0) {
47+
if ($port === 0) {
5048
$port = 8080;
51-
} else {
52-
if (($port < 1 || $port > 65535)) {
53-
$this->markTestSkipped(sprintf(
54-
'%s is not a valid proxy port number. Should be between 1 and 65535.',
55-
$port
56-
));
57-
}
49+
} elseif ($port < 1 || $port > 65535) {
50+
$this->markTestSkipped(sprintf(
51+
'%s is not a valid proxy port number. Should be between 1 and 65535.',
52+
$port
53+
));
5854
}
5955

6056
$this->port = $port;
6157

62-
$user = '';
63-
$pass = '';
64-
if (getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER')
65-
&& getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER')
66-
) {
67-
$user = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER');
68-
}
69-
70-
if (getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS')
71-
&& getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS')
72-
) {
73-
$pass = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS');
74-
}
58+
$user = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') ?: '';
59+
$pass = getenv('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') ?: '';
7560

7661
$this->config = [
7762
'adapter' => Proxy::class,

test/bootstrap.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)