mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Renamed method to be more consistent to what it actually does
This commit is contained in:
parent
a01e0ba337
commit
262a06f624
@ -35,11 +35,11 @@ class ListDomainsCommand extends Command
|
|||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): ?int
|
protected function execute(InputInterface $input, OutputInterface $output): ?int
|
||||||
{
|
{
|
||||||
$regularDomains = $this->domainService->listDomainsWithout();
|
$domains = $this->domainService->listDomains();
|
||||||
|
|
||||||
ShlinkTable::fromOutput($output)->render(
|
ShlinkTable::fromOutput($output)->render(
|
||||||
['Domain', 'Is default'],
|
['Domain', 'Is default'],
|
||||||
map($regularDomains, fn (DomainItem $domain) => [$domain->toString(), $domain->isDefault() ? 'Yes' : 'No']),
|
map($domains, fn (DomainItem $domain) => [$domain->toString(), $domain->isDefault() ? 'Yes' : 'No']),
|
||||||
);
|
);
|
||||||
|
|
||||||
return ExitCodes::EXIT_SUCCESS;
|
return ExitCodes::EXIT_SUCCESS;
|
||||||
|
@ -45,7 +45,7 @@ class ListDomainsCommandTest extends TestCase
|
|||||||
+---------+------------+
|
+---------+------------+
|
||||||
|
|
||||||
OUTPUT;
|
OUTPUT;
|
||||||
$listDomains = $this->domainService->listDomainsWithout()->willReturn([
|
$listDomains = $this->domainService->listDomains()->willReturn([
|
||||||
new DomainItem('foo.com', true),
|
new DomainItem('foo.com', true),
|
||||||
new DomainItem('bar.com', false),
|
new DomainItem('bar.com', false),
|
||||||
new DomainItem('baz.com', false),
|
new DomainItem('baz.com', false),
|
||||||
|
@ -25,7 +25,7 @@ class DomainService implements DomainServiceInterface
|
|||||||
/**
|
/**
|
||||||
* @return DomainItem[]
|
* @return DomainItem[]
|
||||||
*/
|
*/
|
||||||
public function listDomainsWithout(): array
|
public function listDomains(): array
|
||||||
{
|
{
|
||||||
/** @var DomainRepositoryInterface $repo */
|
/** @var DomainRepositoryInterface $repo */
|
||||||
$repo = $this->em->getRepository(Domain::class);
|
$repo = $this->em->getRepository(Domain::class);
|
||||||
|
@ -11,5 +11,5 @@ interface DomainServiceInterface
|
|||||||
/**
|
/**
|
||||||
* @return DomainItem[]
|
* @return DomainItem[]
|
||||||
*/
|
*/
|
||||||
public function listDomainsWithout(): array;
|
public function listDomains(): array;
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,13 @@ class DomainServiceTest extends TestCase
|
|||||||
* @test
|
* @test
|
||||||
* @dataProvider provideExcludedDomains
|
* @dataProvider provideExcludedDomains
|
||||||
*/
|
*/
|
||||||
public function listDomainsWithoutDelegatesIntoRepository(array $domains, array $expectedResult): void
|
public function listDomainsDelegatesIntoRepository(array $domains, array $expectedResult): void
|
||||||
{
|
{
|
||||||
$repo = $this->prophesize(DomainRepositoryInterface::class);
|
$repo = $this->prophesize(DomainRepositoryInterface::class);
|
||||||
$getRepo = $this->em->getRepository(Domain::class)->willReturn($repo->reveal());
|
$getRepo = $this->em->getRepository(Domain::class)->willReturn($repo->reveal());
|
||||||
$findDomains = $repo->findDomainsWithout('default.com')->willReturn($domains);
|
$findDomains = $repo->findDomainsWithout('default.com')->willReturn($domains);
|
||||||
|
|
||||||
$result = $this->domainService->listDomainsWithout();
|
$result = $this->domainService->listDomains();
|
||||||
|
|
||||||
self::assertEquals($expectedResult, $result);
|
self::assertEquals($expectedResult, $result);
|
||||||
$getRepo->shouldHaveBeenCalledOnce();
|
$getRepo->shouldHaveBeenCalledOnce();
|
||||||
|
@ -24,7 +24,7 @@ class ListDomainsAction extends AbstractRestAction
|
|||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$domainItems = $this->domainService->listDomainsWithout();
|
$domainItems = $this->domainService->listDomains();
|
||||||
|
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
'domains' => [
|
'domains' => [
|
||||||
|
@ -33,7 +33,7 @@ class ListDomainsActionTest extends TestCase
|
|||||||
new DomainItem('bar.com', true),
|
new DomainItem('bar.com', true),
|
||||||
new DomainItem('baz.com', false),
|
new DomainItem('baz.com', false),
|
||||||
];
|
];
|
||||||
$listDomains = $this->domainService->listDomainsWithout()->willReturn($domains);
|
$listDomains = $this->domainService->listDomains()->willReturn($domains);
|
||||||
|
|
||||||
/** @var JsonResponse $resp */
|
/** @var JsonResponse $resp */
|
||||||
$resp = $this->action->handle(ServerRequestFactory::fromGlobals());
|
$resp = $this->action->handle(ServerRequestFactory::fromGlobals());
|
||||||
|
Loading…
Reference in New Issue
Block a user