domainService = $this->prophesize(DomainServiceInterface::class); $this->commandTester = $this->testerForCommand(new ListDomainsCommand($this->domainService->reveal())); } /** * @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', )); $listDomains = $this->domainService->listDomains()->willReturn([ DomainItem::forDefaultDomain('foo.com', new NotFoundRedirectOptions([ 'base_url' => 'https://foo.com/default/base', 'invalid_short_url' => 'https://foo.com/default/invalid', ])), DomainItem::forNonDefaultDomain(Domain::withAuthority('bar.com')), DomainItem::forNonDefaultDomain($bazDomain), ]); $this->commandTester->execute($input); self::assertEquals($expectedOutput, $this->commandTester->getDisplay()); self::assertEquals(ExitCodes::EXIT_SUCCESS, $this->commandTester->getStatusCode()); $listDomains->shouldHaveBeenCalledOnce(); } public function provideInputsAndOutputs(): iterable { $withoutRedirectsOutput = << [[], $withoutRedirectsOutput]; yield 'no show redirects' => [['--show-redirects' => false], $withoutRedirectsOutput]; yield 'show redirects' => [['--show-redirects' => true], $withRedirectsOutput]; } }