Closed dcorrea777 closed 2 months ago
I think I've found the right way to do exception testing, I can follow phpunit itself, correct?
Example:
#[Test]
public function itShouldThrowsExceptionWhenBaseIsNotValid(): void
{
$this->expectException(InvalidRuleConstructorException::class);
$this->expectExceptionMessage('a base between 1 and 62 is required');
(new Base(63))->evaluate('011010001');
}
Hey hey! 👋
I've commented on #1457 that it's best not to include the call to the evaluate()
method because it gives the impression that the exception is thrown from that method and not from the Rule's constructor.
Thanks for the reply @henriquemoody
Hey everyone,
I'm looking to get back into contributing to the project and I've been checking out the roadmap for version 3.0. I want to start by increasing the code coverage, but I ran into a few questions.
I've been adding some exception tests using phpt, but I got stuck on the Base rule test. This rule throws an exception called
InvalidRuleConstructorException
. However, it seems like this exception isn't being caught by theexceptionMessage
andexceptionFullMessage
functions. Am I doing something wrong?