request = $this->prophesize("\\Psr\\Http\\Message\\ServerRequestInterface"); $this->response = $this->prophesize("\\Psr\\Http\\Message\\ResponseInterface"); $this->response->withStatus(Argument::any())->willReturn($this->response->reveal()); } public function testDispatchesMiddleware() { $middleware = function ($request, &$response) { $response = $response->withStatus(200); }; $route = new StaticRoute("/", $middleware); $request = $this->request->reveal(); $response = $this->response->reveal(); $route->dispatch($request, $response); $this->response->withStatus(200)->shouldHaveBeenCalled(); } }