-
Notifications
You must be signed in to change notification settings - Fork 241
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
Unclear error message when MethodNotFound #154
Comments
I'm interested in catching and handling this error inside PhpSpec, but don't currently have a way to get the class/interface on which the method should be defined. |
Oh and anecdotally, this is something that is difficult for new learners; they find the message hard to interpret. |
Care to PR? |
It's on my list but thought I'd report first in case someone could pick it up :-) |
I encounter a similar problem recently. Let me know if I should create another issue. When I mock a class but make a typo on the full class name (namespace and class name) then call my method to mock on my |
@flohw I just had this issue too. Scratching my head for a minute there, and this pointed me in the right direction, so thanks! I agree that in this instance it should throw something like |
This is certainly a head-scratcher for newbies - has anyone picked it up? If not I can give it a go. |
I've had a poke around at this but I'm stumped. At the point where the exception is thrown, we have access to the ObjectProphecy, but AFAICT to get from that the name of the class or interface for the prophecy would require getting them from its $lazyDouble property, which isn't accessible. Would be useful to get some direction from maintainers on how to get this to work. My first idea would be to implement __toString() on ObjectProphecy to output a human-friendly string representation of the prophecy for general debugging use. |
Rather than |
Currently when
Prophecy\Exception\Doubler\MethodNotFoundException
is thrown the message and exception includes the class of the double, not the interface or class being doubled.This leads to messages like:
When it would be clearer for users to have something like:
The text was updated successfully, but these errors were encountered: