domainService = $this->createMock(DomainServiceInterface::class); $this->commandTester = CliTestUtils::testerForCommand(new ListDomainsCommand($this->domainService)); } #[Test, DataProvider('provideInputsAndOutputs')] public function allDomainsAreProperlyPrinted(array $input, string $expectedOutput): void { $bazDomain = Domain::withAuthority('baz.com'); $bazDomain->configureNotFoundRedirects(NotFoundRedirects::withRedirects( null, 'https://foo.com/baz-domain/regular', 'https://foo.com/baz-domain/invalid', )); $this->domainService->expects($this->once())->method('listDomains')->with()->willReturn([ DomainItem::forDefaultDomain('foo.com', new NotFoundRedirectOptions( invalidShortUrl: 'https://foo.com/default/invalid', baseUrl: 'https://foo.com/default/base', )), DomainItem::forNonDefaultDomain(Domain::withAuthority('bar.com')), DomainItem::forNonDefaultDomain($bazDomain), ]); $this->commandTester->execute($input); self::assertEquals($expectedOutput, $this->commandTester->getDisplay()); self::assertEquals(ExitCode::EXIT_SUCCESS, $this->commandTester->getStatusCode()); } public static function provideInputsAndOutputs(): iterable { $withoutRedirectsOutput = << [[], $withoutRedirectsOutput]; yield 'no show redirects' => [['--show-redirects' => false], $withoutRedirectsOutput]; yield 'show redirects' => [['--show-redirects' => true], $withRedirectsOutput]; } }