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

Commit

Permalink
Merge branch 'hotfix/28' into develop
Browse files Browse the repository at this point in the history
Forward port #32
  • Loading branch information
weierophinney committed Oct 9, 2015
2 parents c2451bc + df8bf8d commit 22b5547
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ details.

- Nothing.

## 1.1.2 - TBD
## 1.1.2 - 2015-10-09

### Added

Expand All @@ -40,7 +40,11 @@ details.

### Fixed

- Nothing.
- [#32](https://github.com/zendframework/zend-stratigility/pull/32) updates the
request and response typehints in `Zend\Stratigility\Dispatch` to use the
corresponding PSR-7 interfaces, instead of the Stratigility-specific
decorators. This fixes issues when calling `$next()` with non-Stratigility
instances of either.

## 1.1.1 - 2015-08-25

Expand Down
10 changes: 6 additions & 4 deletions src/Dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
namespace Zend\Stratigility;

use Exception;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
* Dispatch middleware
Expand Down Expand Up @@ -42,15 +44,15 @@ class Dispatch
*
* @param Route $route
* @param mixed $err
* @param Http\Request $request
* @param Http\Response $response
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
*/
public function __invoke(
Route $route,
$err,
Http\Request $request,
Http\Response $response,
ServerRequestInterface $request,
ResponseInterface $response,
callable $next
) {
$handler = $route->handler;
Expand Down
24 changes: 24 additions & 0 deletions test/DispatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
namespace ZendTest\Stratigility;

use PHPUnit_Framework_TestCase as TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use RuntimeException;
use Zend\Stratigility\Dispatch;
use Zend\Stratigility\Route;
Expand Down Expand Up @@ -175,4 +177,26 @@ public function testIfErrorHandlerReturnsResponseDispatchReturnsTheResponse()
$result = $dispatch($route, $err, $this->request, $this->response, $next);
$this->assertSame($this->response, $result);
}

/**
* @group 28
*/
public function testShouldAllowDispatchingPsr7Instances()
{
$phpunit = $this;
$handler = function ($req, $res, $next) {
return $res;
};
$next = function ($req, $res, $err) use ($phpunit) {
$phpunit->fail('Next was called; it should not have been');
};

$request = $this->prophesize('Psr\Http\Message\ServerRequestInterface');
$response = $this->prophesize('Psr\Http\Message\ResponseInterface');
$dispatch = new Dispatch();
$route = new Route('/foo', $handler);
$err = null;
$result = $dispatch($route, $err, $request->reveal(), $response->reveal(), $next);
$this->assertSame($response->reveal(), $result);
}
}

0 comments on commit 22b5547

Please sign in to comment.