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

Exception Message is unclear #7

Open
jmauerhan opened this issue Apr 26, 2016 · 3 comments
Open

Exception Message is unclear #7

jmauerhan opened this issue Apr 26, 2016 · 3 comments

Comments

@jmauerhan
Copy link

jmauerhan commented Apr 26, 2016

First of all I just want to say I really like the library, thank you so much for creating it :)

I do think this Exception Message should be improved.

When I create a mocked function like so:

$passthru = $this->getFunctionMock('My\Project', 'passthru');
$passthru->expects($this->exactly(2))->withConsecutive(['arg1'], ['arg2']);

The error message that I get when the test fails (because the code being tested doesn't actually call passthru() yet) is like this:

1) Tests\MyProjectTest::myTestMethod 
Expectation failed for method name is equal to <string:delegate> when invoked 2 time(s).       
Method was expected to be called 2 times, actually called 0 times.                                                                                                                        

Instead of <string:delegate> it would be helpful if it said passthru, or even better, something like: Expectation failed for passthru to be invoked 2 time(s)

I know the matchers and exceptions come from PHPUnit, but is there a way to send in better messages?

@malkusch
Copy link
Member

I noticed this already and started to fix that in the branch useful-message. Unfortunately the time I spent on that was not sufficient to completely understand the PHPUnit model.

I'm happy for any pull requests regarding this topic. It's a valid issue, so I'll leave this here open.

@cj-clx
Copy link

cj-clx commented Jul 29, 2020

I'm glad I found this issue, because I could not for the life of me figure out what the message was trying to tell me.

@jmauerhan
Copy link
Author

I have no idea why I immediately closed the issue, but I'm glad even 4 years later it helped someone :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants