visitsHelper = $this->prophesize(VisitsStatsHelperInterface::class); $this->action = new NonOrphanVisitsAction($this->visitsHelper->reveal()); } /** @test */ public function requestIsHandled(): void { $apiKey = ApiKey::create(); $getVisits = $this->visitsHelper->nonOrphanVisits(Argument::type(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); $getVisits->shouldHaveBeenCalledOnce(); } }