Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase code coverage #1456

Closed
dcorrea777 opened this issue Apr 18, 2024 · 3 comments
Closed

Increase code coverage #1456

dcorrea777 opened this issue Apr 18, 2024 · 3 comments

Comments

@dcorrea777
Copy link
Contributor

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 the exceptionMessage and exceptionFullMessage functions. Am I doing something wrong?

@dcorrea777
Copy link
Contributor Author

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');
}

@henriquemoody
Copy link
Member

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.

@dcorrea777
Copy link
Contributor Author

Thanks for the reply @henriquemoody

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants