notFoundType = $this->prophesize(NotFoundType::class); $this->handler = $this->prophesize(RequestHandlerInterface::class); $this->handler->handle(Argument::cetera())->willReturn(new Response()); $this->requestTracker = $this->prophesize(RequestTrackerInterface::class); $this->middleware = new NotFoundTrackerMiddleware($this->requestTracker->reveal()); $this->request = ServerRequestFactory::fromGlobals()->withAttribute( NotFoundType::class, $this->notFoundType->reveal(), ); } /** @test */ public function delegatesIntoRequestTracker(): void { $this->middleware->process($this->request, $this->handler->reveal()); $this->requestTracker->trackNotFoundIfApplicable($this->request)->shouldHaveBeenCalledOnce(); $this->handler->handle($this->request)->shouldHaveBeenCalledOnce(); } }