Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./test/bootstrap.php"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="zend-http Test Suite">
Expand Down
39 changes: 11 additions & 28 deletions test/Client/CommonHttpTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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!');
}
Expand Down Expand Up @@ -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);
}

Expand All @@ -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!');
Expand All @@ -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!');
}

Expand All @@ -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!');
Expand All @@ -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');
}

Expand All @@ -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()) {
Expand Down Expand Up @@ -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);
}

/**
Expand Down
16 changes: 3 additions & 13 deletions test/Client/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);

Expand Down
37 changes: 11 additions & 26 deletions test/Client/ProxyAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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,
Expand Down
34 changes: 0 additions & 34 deletions test/bootstrap.php

This file was deleted.