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); $route->dispatch($this->request->reveal(), $this->response->reveal()); $this->response->withStatus(200)->shouldHaveBeenCalled(); } }