mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-15 15:42:06 +03:00
60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioTest\Shlink\CLI\Command\Domain;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Prophecy\PhpUnit\ProphecyTrait;
|
|
use Prophecy\Prophecy\ObjectProphecy;
|
|
use Shlinkio\Shlink\CLI\Command\Domain\ListDomainsCommand;
|
|
use Shlinkio\Shlink\CLI\Util\ExitCodes;
|
|
use Shlinkio\Shlink\Core\Domain\DomainServiceInterface;
|
|
use Shlinkio\Shlink\Core\Domain\Model\DomainItem;
|
|
use Symfony\Component\Console\Application;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
class ListDomainsCommandTest extends TestCase
|
|
{
|
|
use ProphecyTrait;
|
|
|
|
private CommandTester $commandTester;
|
|
private ObjectProphecy $domainService;
|
|
|
|
public function setUp(): void
|
|
{
|
|
$this->domainService = $this->prophesize(DomainServiceInterface::class);
|
|
|
|
$command = new ListDomainsCommand($this->domainService->reveal());
|
|
$app = new Application();
|
|
$app->add($command);
|
|
|
|
$this->commandTester = new CommandTester($command);
|
|
}
|
|
|
|
/** @test */
|
|
public function allDomainsAreProperlyPrinted(): void
|
|
{
|
|
$expectedOutput = <<<OUTPUT
|
|
+---------+------------+
|
|
| Domain | Is default |
|
|
+---------+------------+
|
|
| foo.com | Yes |
|
|
| bar.com | No |
|
|
| baz.com | No |
|
|
+---------+------------+
|
|
|
|
OUTPUT;
|
|
$listDomains = $this->domainService->listDomains()->willReturn([
|
|
new DomainItem('foo.com', true),
|
|
new DomainItem('bar.com', false),
|
|
new DomainItem('baz.com', false),
|
|
]);
|
|
|
|
$this->commandTester->execute([]);
|
|
|
|
self::assertEquals($expectedOutput, $this->commandTester->getDisplay());
|
|
self::assertEquals(ExitCodes::EXIT_SUCCESS, $this->commandTester->getStatusCode());
|
|
$listDomains->shouldHaveBeenCalledOnce();
|
|
}
|
|
}
|