Skip to content

Conversation

@duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Jan 26, 2026

This pull request removes negative assertions from our TestCase and the AddonTestCase to workaround the assert($count >= 0) error after a recent PHPUnit change.

I can't see any issues with removing them - apart from a warning from a test calling expectNotToPerformAssertions(). I've removed the expectation for now as I'm not sure how it relates to the purpose of the test. Feel free to add back if you think its necessary.

@duncanmcclean duncanmcclean changed the title [6.x] Remove negative assertions [6.x] Remove negative assertions from TestCase Jan 26, 2026
@duncanmcclean duncanmcclean marked this pull request as ready for review January 26, 2026 12:19
@jasonvarga
Copy link
Member

jasonvarga commented Jan 26, 2026

I can't see any issues with removing them

The assertion counts would be wrong.

e.g. if you have a test like

function test_foo() {
  // blank
}

PHPUnit should warn you that you have no assertions. The mock in the base test case would add to that count, so it would say 1 assertion even if you had none. So we added the negative to counter that.

We added this wangjangling of expectations and assertion counts for earlier versions of Mockery/PHPUnit/etc. I think we can do away with it now. See #6689

@jasonvarga
Copy link
Member

Then that test that had $this->expectNotToPerformAssertions();... well, I'm not sure why that was there. Maybe expectException didn't actually add an assertion once upon a time? Anyway, looks good to just remove it.

@jasonvarga jasonvarga merged commit 80cdd63 into master Jan 26, 2026
11 checks passed
@jasonvarga jasonvarga deleted the assert-count branch January 26, 2026 16:31
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.

3 participants