handler = $this->createMock(RequestHandlerInterface::class); $this->requestTracker = $this->createMock(RequestTrackerInterface::class); $this->middleware = new NotFoundTrackerMiddleware($this->requestTracker); $this->request = ServerRequestFactory::fromGlobals()->withAttribute( NotFoundType::class, $this->createMock(NotFoundType::class), ); } #[Test] public function delegatesIntoRequestTracker(): void { $this->handler->expects($this->once())->method('handle')->with($this->request); $this->requestTracker->expects($this->once())->method('trackNotFoundIfApplicable')->with($this->request); $this->middleware->process($this->request, $this->handler); } }