-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
setMethods deprecation: combining addMethods+onlyMethods is not possible (Cannot use … on … mock because mocked methods were already configured.) #3858
Comments
Same issue here, any news about this? |
Same issue here as well. I agree with kalessil's solution. |
With reference to this comment #3687 (comment) from @sebastianbergmann , I can see one point
I am not sure if this has been decided to |
I thought it would be better to not have them be combinable at first, but now after using them in practice a lot, I do see the use of being able to combine them. The combined use is limited I think, but it's there. The only times it has made sense for them to be combined in the codebase I work on (that has thousands of tests) is a few instances where the AWS SDK is used, which unfortunately abuses magic methods. But there might be other occasions like that so it might make sense to have the ability to combine. |
I agree it totally makes sense to combine to me as well because of the magic methods. One of the ORM that I am using uses a lot of magic methods for getters and setters. I could directly call a function that does not exists
instead of creating a Sometime we might need to mock methods that exists and does not exists together. 😓 |
Superseded by #3911. |
First, I like the split made with the new API =)
Still, setMethods, as I understood from the PR, has recommended replacement by addMethods AND onlyMethods. But implementation requires to use addMethods OR onlyMethods, what is seems to be imcomplete.
In practical field it breaks existing UTs, and gives no possibility to mimic original behavior.
IMO the new methods should be possible to combine as '->onlyMethods(['where', 'first'])->addMethods(['withNoStatusFlags'])'.
The text was updated successfully, but these errors were encountered: