Skip to content

Commit ef630cb

Browse files
committed
updated http-middleware interface to 0.3
1 parent df0d188 commit ef630cb

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## 0.2.0 - 2016-11-22
8+
9+
### Changed
10+
11+
* Updated to `http-interop/http-middleware#0.3`
12+
713
## 0.1.1 - 2016-10-01
814

915
### Fixed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# middlewares/trailing-slash
22

33
[![Latest Version on Packagist][ico-version]][link-packagist]
4-
[![Software License][ico-license]](LICENSE.md)
4+
[![Software License][ico-license]](LICENSE)
55
[![Build Status][ico-travis]][link-travis]
66
[![Quality Score][ico-scrutinizer]][link-scrutinizer]
77
[![Total Downloads][ico-downloads]][link-downloads]
@@ -31,7 +31,7 @@ $dispatcher = new Dispatcher([
3131
->redirect()
3232
]);
3333

34-
$response = $dispatcher->dispatch(new Request());
34+
$response = $dispatcher->dispatch(new ServerRequest());
3535
```
3636

3737
## Options

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
},
1919
"require": {
2020
"php": "^5.6 || ^7.0",
21-
"http-interop/http-middleware": "^0.2",
22-
"middlewares/utils": "0.*"
21+
"http-interop/http-middleware": "^0.3",
22+
"middlewares/utils": "~0.5"
2323
},
2424
"require-dev": {
2525
"phpunit/phpunit": "^5.5",
2626
"zendframework/zend-diactoros": "^1.3",
2727
"friendsofphp/php-cs-fixer": "^1.12",
28-
"squizlabs/php_codesniffer": "^2.7",
29-
"mindplay/middleman": "^2.0"
28+
"squizlabs/php_codesniffer": "^2.7"
3029
},
3130
"autoload": {
3231
"psr-4": {

src/TrailingSlash.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace Middlewares;
44

5-
use Psr\Http\Message\RequestInterface;
5+
use Psr\Http\Message\ServerRequestInterface;
66
use Psr\Http\Message\ResponseInterface;
7-
use Interop\Http\Middleware\MiddlewareInterface;
7+
use Interop\Http\Middleware\ServerMiddlewareInterface;
88
use Interop\Http\Middleware\DelegateInterface;
99

10-
class TrailingSlash implements MiddlewareInterface
10+
class TrailingSlash implements ServerMiddlewareInterface
1111
{
1212
/**
1313
* @var bool Add or remove the slash
@@ -46,12 +46,12 @@ public function redirect($redirect = true)
4646
/**
4747
* Process a request and return a response.
4848
*
49-
* @param RequestInterface $request
50-
* @param DelegateInterface $delegate
49+
* @param ServerRequestInterface $request
50+
* @param DelegateInterface $delegate
5151
*
5252
* @return ResponseInterface
5353
*/
54-
public function process(RequestInterface $request, DelegateInterface $delegate)
54+
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
5555
{
5656
$uri = $request->getUri();
5757
$path = $this->normalize($uri->getPath());

tests/TrailingSlashTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
namespace Middlewares\Tests;
44

55
use Middlewares\TrailingSlash;
6-
use Zend\Diactoros\Request;
6+
use Middlewares\Utils\Dispatcher;
7+
use Middlewares\Utils\CallableMiddleware;
8+
use Zend\Diactoros\ServerRequest;
79
use Zend\Diactoros\Response;
8-
use mindplay\middleman\Dispatcher;
910

1011
class TrailingSlashTest extends \PHPUnit_Framework_TestCase
1112
{
@@ -27,15 +28,15 @@ public function testRemove($url, $result)
2728
$dispatcher = new Dispatcher([
2829
new TrailingSlash(),
2930

30-
function ($request, $next) {
31+
new CallableMiddleware(function ($request, $next) {
3132
$response = new Response();
3233
$response->getBody()->write((string) $request->getUri());
3334

3435
return $response;
35-
},
36+
}),
3637
]);
3738

38-
$response = $dispatcher->dispatch(new Request($url));
39+
$response = $dispatcher->dispatch(new ServerRequest([], [], $url));
3940

4041
$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
4142
$this->assertEquals($result, (string) $response->getBody());
@@ -61,15 +62,15 @@ public function testAdd($url, $result)
6162
$dispatcher = new Dispatcher([
6263
new TrailingSlash(true),
6364

64-
function ($request, $next) {
65+
new CallableMiddleware(function ($request, $next) {
6566
$response = new Response();
6667
$response->getBody()->write((string) $request->getUri());
6768

6869
return $response;
69-
},
70+
}),
7071
]);
7172

72-
$response = $dispatcher->dispatch(new Request($url));
73+
$response = $dispatcher->dispatch(new ServerRequest([], [], $url));
7374

7475
$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
7576
$this->assertEquals($result, (string) $response->getBody());
@@ -81,7 +82,7 @@ public function testRedirect()
8182
(new TrailingSlash())->redirect(),
8283
]);
8384

84-
$response = $dispatcher->dispatch(new Request('/foo/bar/'));
85+
$response = $dispatcher->dispatch(new ServerRequest([], [], '/foo/bar/'));
8586

8687
$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
8788
$this->assertEquals(301, (string) $response->getStatusCode());

0 commit comments

Comments
 (0)