visitsHelper = $this->createMock(VisitsStatsHelperInterface::class); $this->action = new NonOrphanVisitsAction($this->visitsHelper); } #[Test] public function requestIsHandled(): void { $apiKey = ApiKey::create(); $this->visitsHelper->expects($this->once())->method('nonOrphanVisits')->with( $this->isInstanceOf(VisitsParams::class), $apiKey, )->willReturn(new Paginator(new ArrayAdapter([]))); /** @var JsonResponse $response */ $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute(ApiKey::class, $apiKey)); $payload = $response->getPayload(); self::assertEquals(200, $response->getStatusCode()); self::assertArrayHasKey('visits', $payload); } }