Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ public function testValidateToSignWithWrongCodeThrows(): void {
$instance->setCodeSentByUser('654321');

$this->expectException(LibresignException::class);
$this->expectExceptionMessage('Invalid code.');

@vitormattos vitormattos Aug 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does you think about add an error code to this exception?

With an error code we can confirm that is the expected error without matching the text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — I'll add a code so the tests assert expectExceptionCode() instead of the text. Two quick questions before I push:

  1. Should the code follow the "HTTP-like plus one digit" pattern you mentioned (e.g. 4010 for the invalid verification code and 5030 for "Two-Factor Gateway not enabled"), and would you like them as constants, like JSActions?
  2. I'd apply it to both exceptions touched by this PR, unless you prefer only Invalid code. for now.


$instance->validateToSign();
}
Expand All @@ -266,7 +265,6 @@ public function testValidateToSignThrowsWhenCodeWasSentWithoutBeingRequested():
$instance->setCodeSentByUser('123456');

$this->expectException(LibresignException::class);
$this->expectExceptionMessage('Invalid code.');

$instance->validateToSign();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function testSendCodeByGatewayThrowsWhenGatewayAppIsNotEnabled(): void {
->method('generate');

$this->expectException(LibresignException::class);
$this->expectExceptionMessage('App Two-Factor Gateway is not enabled.');

$this->createService()->sendCodeByGateway('+5511999999999', 'sms');
}
Expand Down
Loading