lumen-testing icon indicating copy to clipboard operation
lumen-testing copied to clipboard

During testing of Middleware the Request is not decorated with the routing parameters

Open HenkPoley opened this issue 5 years ago • 0 comments

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)

HenkPoley avatar Jan 08 '20 13:01 HenkPoley