Skip to content
Browse files

[Http] Enable Http tests & Fix PHP 5.4 issue

Headers with multiple values are now rendered splitting the values with commas ','
  • Loading branch information...
1 parent 74e12aa commit 5212e482d0989477dddc4804955d3b1908a15a2f @Maks3w committed May 17, 2012
View
6 library/Zend/Http/Client/Adapter/Curl.php
@@ -336,7 +336,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
default:
// For now, through an exception for unsupported request methods
- throw new AdapterException\InvalidArgumentException("Method currently not supported");
+ throw new AdapterException\InvalidArgumentException("Method '$method' currently not supported");
}
if (is_resource($body) && $curlMethod != CURLOPT_UPLOAD) {
@@ -365,7 +365,9 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
}
// set additional headers
- $headers['Accept'] = '';
+ if (!isset($headers['Accept'])) {
+ $headers['Accept'] = '';
+ }
$curlHeaders = array();
foreach ($headers as $key => $value) {
$curlHeaders[] = $key . ': ' . $value;
View
3 library/Zend/Http/Headers.php
@@ -220,6 +220,9 @@ public function addHeaderLine($headerFieldNameOrLine, $fieldValue = null)
} else {
$headerName = $headerFieldNameOrLine;
$headerKey = str_replace(array('-', '_', ' ', '.'), '', strtolower($headerFieldNameOrLine));
+ if (is_array($fieldValue)) {
+ $fieldValue = implode(', ', $fieldValue);
+ }
$line = $headerFieldNameOrLine . ': ' . $fieldValue;
}
View
2 tests/Zend/Http/Client/CommonHttpTests.php
@@ -346,8 +346,6 @@ public function testHeadersSingle()
foreach ($headers as $key => $val)
$this->assertContains(strtolower("$key: $val"), $body);
-
- $this->assertContains(strtolower($acceptHeader), $body);
}
/**
View
37 tests/Zend/Http/Client/CurlTest.php
@@ -20,6 +20,8 @@
*/
namespace ZendTest\Http\Client;
+
+use Zend\Config\Config;
use Zend\Http\Client\Adapter;
/**
@@ -56,14 +58,25 @@ class CurlTest extends CommonHttpTests
protected function setUp()
{
- $this->markTestIncomplete('cURL implementation incomplete at the moment');
-
if (!extension_loaded('curl')) {
$this->markTestSkipped('cURL is not installed, marking all Http Client Curl Adapter tests skipped.');
}
parent::setUp();
}
+ public function testSimpleRequests()
+ {
+ $this->markTestSkipped('Method PATCH not implemented.');
+ }
+
+ /**
+ * @dataProvider parameterArrayProvider
+ */
+ public function testPatchData($params)
+ {
+ $this->markTestSkipped('Method PATCH not implemented.');
+ }
+
/**
* Off-line common adapter tests
*/
@@ -95,7 +108,7 @@ public function testConfigSetAsArray()
public function testConfigSetAsZendConfig()
{
- $config = new \Zend\Config\Config(array(
+ $config = new Config(array(
'timeout' => 400,
'nested' => array(
'item' => 'value',
@@ -118,7 +131,7 @@ public function testSetConfigInvalidConfig($config)
{
$this->setExpectedException(
'Zend\Http\Client\Adapter\Exception\InvalidArgumentException',
- 'Array or Zend\Config\Config object expected');
+ 'Array or Traversable object expected');
$this->_adapter->setOptions($config);
}
@@ -172,10 +185,6 @@ public function testRedirectWithGetOnly()
*/
public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout()
{
- $this->setExpectedException(
- 'Zend\Http\Client\Adapter\Exception\RuntimeException',
- 'Error in cURL request: Operation timed out after 1000 milliseconds with 0 bytes received');
-
$adapter = new Adapter\Curl();
$this->client->setAdapter($adapter);
$adapter->setOptions(array(
@@ -191,6 +200,9 @@ public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout(
$this->client->setParameterGet(array ('swallow' => 'african'));
$this->client->setParameterPost(array ('Camelot' => 'A silly place'));
$this->client->setMethod('POST');
+ $this->setExpectedException(
+ 'Zend\Http\Client\Adapter\Exception\RuntimeException',
+ 'Error in cURL request: Operation timed out after 1000 milliseconds with 0 bytes received');
$this->client->send();
}
@@ -239,17 +251,16 @@ public function testPutFileHandleWithHttpClient()
public function testWritingAndNotConnectedWithCurlHandleThrowsException()
{
- $this->setExpectedException('Zend\Http\Client\Adapter\Exception', "Trying to write but we are not connected");
-
$adapter = new Adapter\Curl();
+ $this->setExpectedException('Zend\Http\Client\Adapter\Exception\RuntimeException',
+ 'Trying to write but we are not connected');
$adapter->write("GET", "someUri");
}
public function testSetConfigIsNotArray()
{
- $this->setExpectedException('Zend\Http\Client\Adapter\Exception');
-
$adapter = new Adapter\Curl();
+ $this->setExpectedException('Zend\Http\Client\Adapter\Exception\InvalidArgumentException');
$adapter->setOptions("foo");
}
@@ -300,7 +311,7 @@ public function testGetCurlHandle()
$this->assertTrue(is_resource($adapter->getHandle()));
}
-
+
/**
* @group ZF-9857
*/
View
2 tests/Zend/Http/Client/ProxyAdapterTest.php
@@ -47,8 +47,6 @@ class ProxyAdapterTest extends SocketTest
*/
protected function setUp()
{
- $this->markTestIncomplete('Proxy adapter incomplete at the moment');
-
if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') &&
TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) {

0 comments on commit 5212e48

Please sign in to comment.
Something went wrong with that request. Please try again.