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