domainService = $this->prophesize(DomainServiceInterface::class); $this->action = new ListDomainsAction($this->domainService->reveal()); } /** @test */ public function domainsAreProperlyListed(): void { $apiKey = new ApiKey(); $domains = [ new DomainItem('bar.com', true), new DomainItem('baz.com', false), ]; $listDomains = $this->domainService->listDomains($apiKey)->willReturn($domains); /** @var JsonResponse $resp */ $resp = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute(ApiKey::class, $apiKey)); $payload = $resp->getPayload(); self::assertEquals([ 'domains' => [ 'data' => $domains, ], ], $payload); $listDomains->shouldHaveBeenCalledOnce(); } }