-
Notifications
You must be signed in to change notification settings - Fork 13
Fix OPTIONS request for not found routes #73
Conversation
Pass to next handler when route is not matched.
@@ -73,12 +73,11 @@ public function testReturnsResultOfHandlerWhenRouteSupportsOptionsExplicitly() | |||
{ | |||
$route = $this->prophesize(Route::class); | |||
|
|||
$result = $this->prophesize(RouteResult::class); | |||
$result->getMatchedRoute()->will([$route, 'reveal']); | |||
$result = RouteResult::fromRoute($route->reveal()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed here to not mocking the RouteResult because if we use more methods we need always extend our mock.
And what's more we can easily mock RouteResult
wrong way. We can create new instance only by using fromRoute
or fromRouteFailure
but we can create invalid mock as we have to mock 4-5 public methods...
$result = $this->prophesize(RouteResult::class); | ||
$result->getAllowedMethods()->willReturn($allowedMethods); | ||
$result->getMatchedRoute()->willReturn(false); | ||
$result = RouteResult::fromRouteFailure($allowedMethods); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same comment here as above about mocking RouteResult
.
|
||
public function testReturnsResultOfHandlerWhenRouteNotFound() | ||
{ | ||
$result = RouteResult::fromRouteFailure(Route::HTTP_METHOD_ANY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main test, so in case route NOT FOUND we have allowed any methods, but the result is failure.
So isFailure === true
and isMethodFailure === false
. Then -> 404.
Close #73 Fixes #72 Fixes zendframework/zend-expressive-skeleton#245
Forward port #73 Conflicts: CHANGELOG.md
Thanks, @webimpress! |
Pass to next handler when route is not matched.
Fixes #72
master
branch, and submit against that branch.CHANGELOG.md
entry for the fix.