diff options
| author | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:33 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:33 +0100 |
| commit | 71834da8c6f7b24b0c15c57556e053ccd671aa3a (patch) | |
| tree | b60c1da376ad4839b99b0bd533ed536a29f62871 | |
| parent | cfc25964f93e2bdcfec6ac4f3d52c658d66f4d2b (diff) | |
Ensure dispatch runs middleware method
| -rw-r--r-- | src/Router.php | 12 | ||||
| -rw-r--r-- | tests/Unit/RouterTest.php | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/Router.php b/src/Router.php index 62ac52f..46eadd8 100644 --- a/src/Router.php +++ b/src/Router.php @@ -125,13 +125,15 @@ class Router return $this->strategy->notFound($request); } - $call = new RouteCall( + return $this->strategy->runMiddleware( $request, - $match->route, - $match->segmentMatch->parameters, + [], + fn ($request) => $this->strategy->runRoute(new RouteCall( + $request, + $match->route, + $match->segmentMatch->parameters, + )) ); - - return $this->strategy->runRoute($call); } public function make( diff --git a/tests/Unit/RouterTest.php b/tests/Unit/RouterTest.php index a8769c4..4a92381 100644 --- a/tests/Unit/RouterTest.php +++ b/tests/Unit/RouterTest.php @@ -197,6 +197,10 @@ it('calls strategy runRoute with dispatch on match', function () { ->with(Mockery::type(RouteCall::class)) ->andReturn($response); + $strat->shouldReceive('runMiddleware') + ->with($request, [], Mockery::type('callable')) + ->andReturn($response); + $router->setStrategy($strat); $result = $router->dispatch($request); expect($result)->toBe($response); |
