Changed to kebab-case for CLI flags in command tests

This commit is contained in:
Alejandro Celaya 2021-01-30 11:25:20 +01:00
parent 248d5e2fe5
commit 752ded2f80
5 changed files with 16 additions and 16 deletions

View File

@ -55,7 +55,7 @@ class GenerateKeyCommandTest extends TestCase
$this->apiKeyService->create(Argument::type(Chronos::class))->shouldBeCalledOnce() $this->apiKeyService->create(Argument::type(Chronos::class))->shouldBeCalledOnce()
->willReturn(new ApiKey()); ->willReturn(new ApiKey());
$this->commandTester->execute([ $this->commandTester->execute([
'--expirationDate' => '2016-01-01', '--expiration-date' => '2016-01-01',
]); ]);
} }
} }

View File

@ -39,7 +39,7 @@ class ListKeysCommandTest extends TestCase
{ {
$listKeys = $this->apiKeyService->listKeys($enabledOnly)->willReturn($keys); $listKeys = $this->apiKeyService->listKeys($enabledOnly)->willReturn($keys);
$this->commandTester->execute(['--enabledOnly' => $enabledOnly]); $this->commandTester->execute(['--enabled-only' => $enabledOnly]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
self::assertEquals($expected, $output); self::assertEquals($expected, $output);

View File

@ -48,7 +48,7 @@ class GenerateShortUrlCommandTest extends TestCase
$this->commandTester->execute([ $this->commandTester->execute([
'longUrl' => 'http://domain.com/foo/bar', 'longUrl' => 'http://domain.com/foo/bar',
'--maxVisits' => '3', '--max-visits' => '3',
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
@ -78,7 +78,7 @@ class GenerateShortUrlCommandTest extends TestCase
NonUniqueSlugException::fromSlug('my-slug'), NonUniqueSlugException::fromSlug('my-slug'),
); );
$this->commandTester->execute(['longUrl' => 'http://domain.com/invalid', '--customSlug' => 'my-slug']); $this->commandTester->execute(['longUrl' => 'http://domain.com/invalid', '--custom-slug' => 'my-slug']);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
self::assertEquals(ExitCodes::EXIT_FAILURE, $this->commandTester->getStatusCode()); self::assertEquals(ExitCodes::EXIT_FAILURE, $this->commandTester->getStatusCode());

View File

@ -71,8 +71,8 @@ class GetVisitsCommandTest extends TestCase
$this->commandTester->execute([ $this->commandTester->execute([
'shortCode' => $shortCode, 'shortCode' => $shortCode,
'--startDate' => $startDate, '--start-date' => $startDate,
'--endDate' => $endDate, '--end-date' => $endDate,
]); ]);
} }
@ -86,7 +86,7 @@ class GetVisitsCommandTest extends TestCase
$this->commandTester->execute([ $this->commandTester->execute([
'shortCode' => $shortCode, 'shortCode' => $shortCode,
'--startDate' => $startDate, '--start-date' => $startDate,
]); ]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();

View File

@ -104,7 +104,7 @@ class ListShortUrlsCommandTest extends TestCase
->shouldBeCalledOnce(); ->shouldBeCalledOnce();
$this->commandTester->setInputs(['y']); $this->commandTester->setInputs(['y']);
$this->commandTester->execute(['--showTags' => true]); $this->commandTester->execute(['--show-tags' => true]);
$output = $this->commandTester->getDisplay(); $output = $this->commandTester->getDisplay();
self::assertStringContainsString('Tags', $output); self::assertStringContainsString('Tags', $output);
} }
@ -139,22 +139,22 @@ class ListShortUrlsCommandTest extends TestCase
{ {
yield [[], 1, null, []]; yield [[], 1, null, []];
yield [['--page' => $page = 3], $page, null, []]; yield [['--page' => $page = 3], $page, null, []];
yield [['--searchTerm' => $searchTerm = 'search this'], 1, $searchTerm, []]; yield [['--search-term' => $searchTerm = 'search this'], 1, $searchTerm, []];
yield [ yield [
['--page' => $page = 3, '--searchTerm' => $searchTerm = 'search this', '--tags' => $tags = 'foo,bar'], ['--page' => $page = 3, '--search-term' => $searchTerm = 'search this', '--tags' => $tags = 'foo,bar'],
$page, $page,
$searchTerm, $searchTerm,
explode(',', $tags), explode(',', $tags),
]; ];
yield [ yield [
['--startDate' => $startDate = '2019-01-01'], ['--start-date' => $startDate = '2019-01-01'],
1, 1,
null, null,
[], [],
$startDate, $startDate,
]; ];
yield [ yield [
['--endDate' => $endDate = '2020-05-23'], ['--end-date' => $endDate = '2020-05-23'],
1, 1,
null, null,
[], [],
@ -162,7 +162,7 @@ class ListShortUrlsCommandTest extends TestCase
$endDate, $endDate,
]; ];
yield [ yield [
['--startDate' => $startDate = '2019-01-01', '--endDate' => $endDate = '2020-05-23'], ['--start-date' => $startDate = '2019-01-01', '--end-date' => $endDate = '2020-05-23'],
1, 1,
null, null,
[], [],
@ -191,9 +191,9 @@ class ListShortUrlsCommandTest extends TestCase
public function provideOrderBy(): iterable public function provideOrderBy(): iterable
{ {
yield [[], null]; yield [[], null];
yield [['--orderBy' => 'foo'], 'foo']; yield [['--order-by' => 'foo'], 'foo'];
yield [['--orderBy' => 'foo,ASC'], ['foo' => 'ASC']]; yield [['--order-by' => 'foo,ASC'], ['foo' => 'ASC']];
yield [['--orderBy' => 'bar,DESC'], ['bar' => 'DESC']]; yield [['--order-by' => 'bar,DESC'], ['bar' => 'DESC']];
} }
/** @test */ /** @test */