Skip to content

Commit

Permalink
updated http-middleware interface to 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 23, 2016
1 parent 951b006 commit 8ab6878
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 0.2.0 - 2016-11-23

### Changed

* Updated to `http-interop/http-middleware#0.3`

## 0.1.1 - 2016-10-01

### Fixed
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# middlewares/method-override

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Software License][ico-license]](LICENSE)
[![Build Status][ico-travis]][link-travis]
[![Quality Score][ico-scrutinizer]][link-scrutinizer]
[![Total Downloads][ico-downloads]][link-downloads]
[![SensioLabs Insight][ico-sensiolabs]][link-sensiolabs]

Middleware to override the request method using the `X-Http-Method-Override` header. This is useful for clients unable to send other methods than GET and POST.

**Note:** This middleware is intended for server side only

## Requirements

* PHP >= 5.6
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
},
"require": {
"php": "^5.6 || ^7.0",
"http-interop/http-middleware": "^0.2",
"middlewares/utils": "0.*"
"http-interop/http-middleware": "^0.3",
"middlewares/utils": "~0.5"
},
"require-dev": {
"phpunit/phpunit": "^5.5",
"zendframework/zend-diactoros": "^1.3",
"friendsofphp/php-cs-fixer": "^1.12",
"squizlabs/php_codesniffer": "^2.7",
"mindplay/middleman": "^2.0"
"squizlabs/php_codesniffer": "^2.7"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 8 additions & 5 deletions tests/MethodOverrideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Middlewares\Tests;

use Middlewares\MethodOverride;
use Middlewares\Utils\Dispatcher;
use Middlewares\Utils\CallableMiddleware;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\Response;
use mindplay\middleman\Dispatcher;

class MethodOverrideTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -32,11 +33,12 @@ public function testHeaders($original, $overrided, $status, $body)
$response = (new Dispatcher([
new MethodOverride(),

function ($request) {
new CallableMiddleware(function ($request) {
$response = new Response();
$response->getBody()->write($request->getMethod());

return $response;
},
}),
]))->dispatch($request);

$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
Expand Down Expand Up @@ -72,11 +74,12 @@ public function testParams($original, $queryParams, $parsedBody, $status, $body)
->parsedBodyParameter('method')
->queryParameter('method'),

function ($request) {
new CallableMiddleware(function ($request) {
$response = new Response();
$response->getBody()->write($request->getMethod());

return $response;
},
}),
]))->dispatch($request);

$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
Expand Down

0 comments on commit 8ab6878

Please sign in to comment.