lumen-testing
lumen-testing copied to clipboard
During testing of Middleware the Request is not decorated with the routing parameters
Normally Lumen decorates the Request with the routing parameters.
E.g. in routes/web.php
:
$router->group(['prefix' => '/{prefixId:[0-9]+}'], function () use ($router) {
$router->get('/something/{somethingId:[0-9]+}', 'SomethingController@show');
}
You would be able to attach a middleware to the group()
or the get()
, and access $request->prefixId
or $request->somethingId
.
public function handle(Request $request, Closure $next)
{
if(42 === (int) $request->prefixId) return null;
if(1 === (int) $request->somethingId) return null;
return $next($request);
}
This does not work under lumen-testing.
(I guess this is related to Issue #18)