-
Notifications
You must be signed in to change notification settings - Fork 456
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
allows() and expects() syntax #668
Merged
davedevelopment
merged 19 commits into
mockery:master
from
davedevelopment:allows-syntax
Jan 27, 2017
Merged
allows() and expects() syntax #668
davedevelopment
merged 19 commits into
mockery:master
from
davedevelopment:allows-syntax
Jan 27, 2017
Conversation
This file contains 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
davedevelopment
force-pushed
the
allows-syntax
branch
3 times, most recently
from
January 19, 2017 07:50
52de6e3
to
1b27307
Compare
Regarding my todo item on no args vs any args, there's a slight difference in behaviour between the old and the new syntax. Previously: $double->shouldReceive("foobar")->andReturn(123);
$double->foobar(); // int(123)
$double->foobar(123); // int(123)
$double->foobar(true, "some string", 5.4); // int(123) With the new syntax: $double->allows()->foo()->andReturns(123);
$double->foo(); // int(123);
$double->foo(123); // Uncaught Exception Mockery\Exception\NoMatchingExpectationException That is, when we say $double->allows()->bar()->withAnyArgs()->andReturns(123);
$double->bar(); // int(123);
$double->bar(123); // int(123) I am fine with this, but I'm curious as to what other people think... |
davedevelopment
force-pushed
the
allows-syntax
branch
from
January 27, 2017 20:47
a6dd6a9
to
5ffcc2e
Compare
davedevelopment
changed the title
WIP ->allows() and ->expects() syntax
allows() and expects() syntax
Jan 27, 2017
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.
Further to #598
expects()
for setting up mock expectationsallows()
for stubbing methodsDespite the new methods on the mocks, this is fully BC as they are skipped if the class to be mocked contains matching methods.
I personally prefer this syntax, but I haven't put it to much use. It's always bothered me that
shouldReceive()
starts withshould
, when it doesn't actually form a mock expectation without the additional call to->once()
or one of the other count methods.My objectives here are not to remove the existing methods, but rather try and encourage the new methods going forward.
Todo