-
Notifications
You must be signed in to change notification settings - Fork 25
Route name in RouteResult is route path not name #3
Conversation
I'll see if I can create a reproduce case, and get back to you. |
Verified; I'll get a fix in shortly. |
Awesome! Glad to see you get to this so quickly. Just wrote some code and came across this and it was holding me back, so this is great. |
Updates `marshalMatchedRoute()` to return the matched route from its internal `array_reduce()` operation, which ensures that we can marshal `RouteResult` with the route *name* instead of the *path*.
@@ -154,7 +154,7 @@ public function testMatchingRouteShouldReturnSuccessfulRouteResult() | |||
$result = $router->match($request->reveal()); | |||
$this->assertInstanceOf(RouteResult::class, $result); | |||
$this->assertTrue($result->isSuccess()); | |||
$this->assertEquals('/foo', $result->getMatchedRouteName()); | |||
$this->assertEquals('/foo^GET', $result->getMatchedRouteName()); |
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.
A note to anybody who stumbles across this: by fixing the issue, I exposed a problem with this particular test. The assumption was that the route name was simply the path. However, that's not the case, nor has it been, for most of the lifetime of this implementation; in order to distinguish between middleware using the same path but different HTTP methods, we had to append the method information auto-magically. Updating the code to return the name picked that up, and hence the change to this assertion.
@nesl247 Fixed, and a new version, 1.0.1, is released with the fix; thanks for the report! |
Looking at the
RouteResult
in thepsrRequest
shows the route path such as/customer/create
as thematchedRouteName
rather thancustomer.create
which is what is specified in the route configuration as such:I'm not sure if this is the intention or not. If it isn't a bug like I suspect it is, what is the purpose of the name then?
The specific line is https://github.com/zendframework/zend-expressive-fastroute/blob/master/src/FastRouteRouter.php#L236