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

Fix negative assertion counts #6689

Merged
merged 1 commit into from
Sep 9, 2022
Merged

Conversation

jasonvarga
Copy link
Member

In our base test class, we have a couple of mocks that fake the version and nav being built.

In versions of Mockery prior to 1.5.1, this would add an assertion count, but we didn't care about it actually counting it, so we negated it.

For example:

\Facades\Statamic\Version::shouldReceive('get')->andReturn('3.0.0-testing');
$this->addToAssertionCount(-1); // Dont want to assert this

In Mockery 1.5.1, they fixed it so that if you aren't actually counting the number of times the method is called, it doesn't consider it an assertion. mockery/mockery#1180

So now our tests can go into the negative.

OK (1 test, -1 assertions)

We could bump the mockery requirement to 1.5.1 and remove the $this->addToAssertionCount(-1), but it's a bit hairy with all the different versions of Laravel/PHP/etc we test with. The simpler solution was this PR, where we add a zeroOrMoreTimes expectation. That'll make sure it gets counted, then we can continue to un-count it.

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

Successfully merging this pull request may close these issues.

None yet

1 participant