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

Commit d976b4b

Browse files
committed
Merge branch 'hotfix/tests' of https://github.com/Maks3w/zf2 into hotfix/tests
6 parents 0706bbd + 57cde95 + c750616 + ac7c7af + 293054e + 85b6555 commit d976b4b

File tree

6 files changed

+35
-25
lines changed

6 files changed

+35
-25
lines changed

src/Client/Adapter/Curl.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
336336

337337
default:
338338
// For now, through an exception for unsupported request methods
339-
throw new AdapterException\InvalidArgumentException("Method currently not supported");
339+
throw new AdapterException\InvalidArgumentException("Method '$method' currently not supported");
340340
}
341341

342342
if (is_resource($body) && $curlMethod != CURLOPT_UPLOAD) {
@@ -372,7 +372,9 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
372372
}
373373

374374
// set additional headers
375-
$headers['Accept'] = '';
375+
if (!isset($headers['Accept'])) {
376+
$headers['Accept'] = '';
377+
}
376378
$curlHeaders = array();
377379
foreach ($headers as $key => $value) {
378380
$curlHeaders[] = $key . ': ' . $value;

src/Client/Adapter/Test.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
use Traversable;
2525
use Zend\Stdlib\ArrayUtils;
26-
use Zend\Http\Client\Adapter\AdapterInterface as HttpAdapter;
27-
use Zend\Http\Client\Adapter\Exception as AdapterException;
2826
use Zend\Http\Response;
2927

3028
/**
@@ -41,7 +39,7 @@
4139
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
4240
* @license http://framework.zend.com/license/new-bsd New BSD License
4341
*/
44-
class Test implements HttpAdapter
42+
class Test implements AdapterInterface
4543
{
4644
/**
4745
* Parameters array
@@ -103,7 +101,7 @@ public function setOptions($options = array())
103101
}
104102

105103
if (! is_array($options)) {
106-
throw new AdapterException\InvalidArgumentException(
104+
throw new Exception\InvalidArgumentException(
107105
'Array or Traversable object expected, got ' . gettype($options)
108106
);
109107
}
@@ -121,13 +119,13 @@ public function setOptions($options = array())
121119
* @param int $port
122120
* @param boolean $secure
123121
* @param int $timeout
124-
* @throws AdapterException\RuntimeException
122+
* @throws Exception\RuntimeException
125123
*/
126124
public function connect($host, $port = 80, $secure = false)
127125
{
128126
if ($this->_nextRequestWillFail) {
129127
$this->_nextRequestWillFail = false;
130-
throw new AdapterException\RuntimeException('Request failed');
128+
throw new Exception\RuntimeException('Request failed');
131129
}
132130
}
133131

@@ -224,7 +222,7 @@ public function addResponse($response)
224222
public function setResponseIndex($index)
225223
{
226224
if ($index < 0 || $index >= count($this->responses)) {
227-
throw new AdapterException\OutOfRangeException(
225+
throw new Exception\OutOfRangeException(
228226
'Index out of range of response buffer size');
229227
}
230228
$this->responseIndex = $index;

src/Headers.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ public function addHeaderLine($headerFieldNameOrLine, $fieldValue = null)
220220
} else {
221221
$headerName = $headerFieldNameOrLine;
222222
$headerKey = str_replace(array('-', '_', ' ', '.'), '', strtolower($headerFieldNameOrLine));
223+
if (is_array($fieldValue)) {
224+
$fieldValue = implode(', ', $fieldValue);
225+
}
223226
$line = $headerFieldNameOrLine . ': ' . $fieldValue;
224227
}
225228

test/Client/CommonHttpTests.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ public function testHeadersSingle()
346346

347347
foreach ($headers as $key => $val)
348348
$this->assertContains(strtolower("$key: $val"), $body);
349-
350-
$this->assertContains(strtolower($acceptHeader), $body);
351349
}
352350

353351
/**

test/Client/CurlTest.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121

2222
namespace ZendTest\Http\Client;
23+
24+
use Zend\Config\Config;
2325
use Zend\Http\Client\Adapter;
2426

2527
/**
@@ -56,14 +58,25 @@ class CurlTest extends CommonHttpTests
5658

5759
protected function setUp()
5860
{
59-
$this->markTestIncomplete('cURL implementation incomplete at the moment');
60-
6161
if (!extension_loaded('curl')) {
6262
$this->markTestSkipped('cURL is not installed, marking all Http Client Curl Adapter tests skipped.');
6363
}
6464
parent::setUp();
6565
}
6666

67+
public function testSimpleRequests()
68+
{
69+
$this->markTestSkipped('Method PATCH not implemented.');
70+
}
71+
72+
/**
73+
* @dataProvider parameterArrayProvider
74+
*/
75+
public function testPatchData($params)
76+
{
77+
$this->markTestSkipped('Method PATCH not implemented.');
78+
}
79+
6780
/**
6881
* Off-line common adapter tests
6982
*/
@@ -95,7 +108,7 @@ public function testConfigSetAsArray()
95108
public function testConfigSetAsZendConfig()
96109
{
97110

98-
$config = new \Zend\Config\Config(array(
111+
$config = new Config(array(
99112
'timeout' => 400,
100113
'nested' => array(
101114
'item' => 'value',
@@ -118,7 +131,7 @@ public function testSetConfigInvalidConfig($config)
118131
{
119132
$this->setExpectedException(
120133
'Zend\Http\Client\Adapter\Exception\InvalidArgumentException',
121-
'Array or Zend\Config\Config object expected');
134+
'Array or Traversable object expected');
122135

123136
$this->_adapter->setOptions($config);
124137
}
@@ -172,10 +185,6 @@ public function testRedirectWithGetOnly()
172185
*/
173186
public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout()
174187
{
175-
$this->setExpectedException(
176-
'Zend\Http\Client\Adapter\Exception\RuntimeException',
177-
'Error in cURL request: Operation timed out after 1000 milliseconds with 0 bytes received');
178-
179188
$adapter = new Adapter\Curl();
180189
$this->client->setAdapter($adapter);
181190
$adapter->setOptions(array(
@@ -191,6 +200,9 @@ public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout(
191200
$this->client->setParameterGet(array ('swallow' => 'african'));
192201
$this->client->setParameterPost(array ('Camelot' => 'A silly place'));
193202
$this->client->setMethod('POST');
203+
$this->setExpectedException(
204+
'Zend\Http\Client\Adapter\Exception\RuntimeException',
205+
'Error in cURL request: Operation timed out after 1000 milliseconds with 0 bytes received');
194206
$this->client->send();
195207
}
196208

@@ -239,17 +251,16 @@ public function testPutFileHandleWithHttpClient()
239251

240252
public function testWritingAndNotConnectedWithCurlHandleThrowsException()
241253
{
242-
$this->setExpectedException('Zend\Http\Client\Adapter\Exception', "Trying to write but we are not connected");
243-
244254
$adapter = new Adapter\Curl();
255+
$this->setExpectedException('Zend\Http\Client\Adapter\Exception\RuntimeException',
256+
'Trying to write but we are not connected');
245257
$adapter->write("GET", "someUri");
246258
}
247259

248260
public function testSetConfigIsNotArray()
249261
{
250-
$this->setExpectedException('Zend\Http\Client\Adapter\Exception');
251-
252262
$adapter = new Adapter\Curl();
263+
$this->setExpectedException('Zend\Http\Client\Adapter\Exception\InvalidArgumentException');
253264
$adapter->setOptions("foo");
254265
}
255266

test/Client/ProxyAdapterTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class ProxyAdapterTest extends SocketTest
4747
*/
4848
protected function setUp()
4949
{
50-
$this->markTestIncomplete('Proxy adapter incomplete at the moment');
51-
5250
if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') &&
5351
TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) {
5452

0 commit comments

Comments
 (0)