Updated CLI commands to just print exception messages when possible

This commit is contained in:
Alejandro Celaya
2019-11-28 18:42:27 +01:00
parent d83d2f82bd
commit 5055ddf995
14 changed files with 40 additions and 97 deletions

View File

@@ -29,7 +29,7 @@ class DisableKeyCommandTest extends TestCase
}
/** @test */
public function providedApiKeyIsDisabled()
public function providedApiKeyIsDisabled(): void
{
$apiKey = 'abcd1234';
$this->apiKeyService->disable($apiKey)->shouldBeCalledOnce();
@@ -43,17 +43,18 @@ class DisableKeyCommandTest extends TestCase
}
/** @test */
public function errorIsReturnedIfServiceThrowsException()
public function errorIsReturnedIfServiceThrowsException(): void
{
$apiKey = 'abcd1234';
$disable = $this->apiKeyService->disable($apiKey)->willThrow(InvalidArgumentException::class);
$expectedMessage = 'API key "abcd1234" does not exist.';
$disable = $this->apiKeyService->disable($apiKey)->willThrow(new InvalidArgumentException($expectedMessage));
$this->commandTester->execute([
'apiKey' => $apiKey,
]);
$output = $this->commandTester->getDisplay();
$this->assertStringContainsString('API key "abcd1234" does not exist.', $output);
$this->assertStringContainsString($expectedMessage, $output);
$disable->shouldHaveBeenCalledOnce();
}
}