helper = $this->prophesize(VisitsStatsHelperInterface::class); $this->action = new GlobalVisitsAction($this->helper->reveal()); } /** @test */ public function statsAreReturnedFromHelper(): void { $apiKey = ApiKey::create(); $stats = new VisitsStats(5, 3); $getStats = $this->helper->getVisitsStats($apiKey)->willReturn($stats); /** @var JsonResponse $resp */ $resp = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute(ApiKey::class, $apiKey)); $payload = $resp->getPayload(); self::assertEquals($payload, ['visits' => $stats]); $getStats->shouldHaveBeenCalledOnce(); } }