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->equalTo($this->request)); $this->requestTracker->expects($this->once())->method('trackNotFoundIfApplicable')->with( $this->equalTo($this->request), ); $this->middleware->process($this->request, $this->handler); } }