domainService = $this->createMock(DomainServiceInterface::class); $this->options = new NotFoundRedirectOptions(); $this->action = new ListDomainsAction($this->domainService, $this->options); } /** @test */ public function domainsAreProperlyListed(): void { $apiKey = ApiKey::create(); $domains = [ DomainItem::forDefaultDomain('bar.com', new NotFoundRedirectOptions()), DomainItem::forNonDefaultDomain(Domain::withAuthority('baz.com')), ]; $this->domainService->expects($this->once())->method('listDomains')->with($apiKey)->willReturn($domains); /** @var JsonResponse $resp */ $resp = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute(ApiKey::class, $apiKey)); $payload = $resp->getPayload(); self::assertEquals([ 'domains' => [ 'data' => $domains, 'defaultRedirects' => NotFoundRedirects::fromConfig($this->options), ], ], $payload); } }