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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into cach…
Browse files Browse the repository at this point in the history
…e_beta2

Conflicts:
	library/Zend/Cache/Cache.php
  • Loading branch information
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public function getUri()
*/
public function setMethod($method)
{
$this->getRequest()->setMethod($method);
$method = $this->getRequest()->setMethod($method)->getMethod();

if (($method == Request::METHOD_POST || $method == Request::METHOD_PUT ||
$method == Request::METHOD_DELETE) && empty($this->encType)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public static function fromString($string)
*/
public function setMethod($method)
{
if (!defined('static::METHOD_'.strtoupper($method))) {
$method = strtoupper($method);
if (!defined('static::METHOD_'.$method)) {
throw new Exception\InvalidArgumentException('Invalid HTTP method passed');
}
$this->method = $method;
Expand Down
22 changes: 22 additions & 0 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ class Response extends Message implements ResponseDescription
const STATUS_CODE_CUSTOM = 0;
const STATUS_CODE_100 = 100;
const STATUS_CODE_101 = 101;
const STATUS_CODE_102 = 102;
const STATUS_CODE_200 = 200;
const STATUS_CODE_201 = 201;
const STATUS_CODE_202 = 202;
const STATUS_CODE_203 = 203;
const STATUS_CODE_204 = 204;
const STATUS_CODE_205 = 205;
const STATUS_CODE_206 = 206;
const STATUS_CODE_207 = 207;
const STATUS_CODE_208 = 208;
const STATUS_CODE_300 = 300;
const STATUS_CODE_301 = 301;
const STATUS_CODE_302 = 302;
Expand Down Expand Up @@ -48,6 +51,11 @@ class Response extends Message implements ResponseDescription
const STATUS_CODE_416 = 416;
const STATUS_CODE_417 = 417;
const STATUS_CODE_418 = 418;
const STATUS_CODE_422 = 422;
const STATUS_CODE_423 = 423;
const STATUS_CODE_424 = 424;
const STATUS_CODE_425 = 425;
const STATUS_CODE_426 = 426;
const STATUS_CODE_428 = 428;
const STATUS_CODE_429 = 429;
const STATUS_CODE_431 = 431;
Expand All @@ -57,6 +65,9 @@ class Response extends Message implements ResponseDescription
const STATUS_CODE_503 = 503;
const STATUS_CODE_504 = 504;
const STATUS_CODE_505 = 505;
const STATUS_CODE_506 = 506;
const STATUS_CODE_507 = 507;
const STATUS_CODE_508 = 508;
const STATUS_CODE_511 = 511;

/**#@-*/
Expand All @@ -80,6 +91,7 @@ class Response extends Message implements ResponseDescription
// INFORMATIONAL CODES
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
// SUCCESS CODES
200 => 'OK',
201 => 'Created',
Expand All @@ -88,6 +100,8 @@ class Response extends Message implements ResponseDescription
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
207 => 'Multi-status',
208 => 'Already Reported',
// REDIRECTION CODES
300 => 'Multiple Choices',
301 => 'Moved Permanently',
Expand Down Expand Up @@ -117,6 +131,11 @@ class Response extends Message implements ResponseDescription
416 => 'Requested range not satisfiable',
417 => 'Expectation Failed',
418 => 'I\'m a teapot',
422 => 'Unprocessable Entity',
423 => 'Locked',
424 => 'Failed Dependency',
425 => 'Unordered Collection',
426 => 'Upgrade Required',
428 => 'Precondition Required',
429 => 'Too Many Requests',
431 => 'Request Header Fields Too Large',
Expand All @@ -127,6 +146,9 @@ class Response extends Message implements ResponseDescription
503 => 'Service Unavailable',
504 => 'Gateway Time-out',
505 => 'HTTP Version not supported',
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
508 => 'Loop Detected',
511 => 'Network Authentication Required',
);

Expand Down
18 changes: 18 additions & 0 deletions test/ClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/**
* @namespace
*/
namespace ZendTest\Http;

use Zend\Http\Client;

class ClientTest extends \PHPUnit_Framework_TestCase
{
public function testClientRetrievesUppercaseHttpMethodFromRequestObject()
{
$client = new Client;
$client->setMethod('post');
$this->assertEquals(Client::ENC_URLENCODED, $client->getEncType());
}
}
7 changes: 7 additions & 0 deletions test/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ public function testRequestCanSetAndRetrieveValidMethod()
$this->assertEquals('POST', $request->getMethod());
}

public function testRequestCanAlwaysForcesUppecaseMethodName()
{
$request = new Request();
$request->setMethod('get');
$this->assertEquals('GET', $request->getMethod());
}

public function testRequestCanSetAndRetrieveUri()
{
$request = new Request();
Expand Down

0 comments on commit 35405a2

Please # to comment.