DE-138979 Create DisallowMockeryShouldReceiveRule to disallow using MockInterface::shouldReceive() in favour of MockInterface::expects() - #107
Merged
Conversation
dominikkaluza
commented
Aug 5, 2025
Comment on lines
+14
to
+17
| - | ||
| class: BrandEmbassyCodingStandard\PhpStan\Rules\Mockery\DisallowMockeryShouldReceiveRule | ||
| tags: | ||
| - phpstan.rules.rule |
Collaborator
Author
There was a problem hiding this comment.
I wasn't sure about enabling it by default, but it seems like the right call since we've accepted the devsync issue. Baseline should be regenerated and that's it.
dorrogeray
approved these changes
Aug 5, 2025
The configuration was causing problems with phpunit tests because of some constant conflicts
dominikkaluza
force-pushed
the
DE-138979-mockery-expects-phpstan-rule
branch
from
August 5, 2025 08:45
e529e49 to
c83377f
Compare
Collaborator
Author
|
@dominik-vasicek reviewed and approved but he's unable to do it through GitHub currently since he's locked out of his computer 😹 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Create
DisallowMockeryShouldReceiveRuleto disallow usingMockInterface::shouldReceive()in favour ofMockInterface::expects().shouldReceivedoesn't enforce call count assertions, so then we find out we have tests like these in the codebase https://github.com/BrandEmbassy/channel-integrations/commit/b200ce77d07363c90ea83a67eeabab4796072cca. The expectations apply to only one of four test cases, but they were in setup because call count wasn't set up and everything was passing -> confusing.We've agreed on this a long time ago here https://github.com/BrandEmbassy/developers-manifest/issues/631 but noone implemented the rule yet. This rule is just to forbid new occurrences. Next step could be to implement a Rector rule that transforms current usage.
There are also changes which fix phpunit runner. It's failing with the current configuration because of some constants conflicts.