-
Notifications
You must be signed in to change notification settings - Fork 154
Conversation
Enable use of will('something') instead of will($this->returnValue('something'))
great addition. It would make <?php
$mock->with($this->equalsTo($foo));
$mock->will($this->returnValue($foo));
// and
$mock->with($foo);
$mock->will($foo); 👍 |
I've actually thought about this a lot in the past. What I think makes more sense is to replace |
I'd also like to see
|
I like @whatthejeff's proposal, makes a lot of sense to me. |
I've opened a separate PR (#146) for @whatthejeff's second proposal about making expects() optional - it makes very good sense to me. |
On this subject it would be nice to allow both will('foo') and willReturn('foo') as aliases. The former fits with the existing pattern for with(), the latter is more verbose and clear. It would be nice to give authors the option. |
@@ -59,8 +59,8 @@ | |||
* Stubs the matching method with the stub object $stub. Any invocations of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a comment about what happens with a scalar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added below.
These might be nice too: $stub->method('doSomething')->willReturnMap(...);
$stub->method('doSomething')->willReturnArgument(...);
$stub->method('doSomething')->willReturnCallback(...);
$stub->method('doSomething')->willReturnSelf(...);
$stub->method('doSomething')->willReturnOnConsecutiveCalls(...);
$stub->method('doSomething')->willThrowException(...); |
I like @whatthejeff's suggestions, don't think they block merging this though? Then either @fabian or someone else could do a separate PR for the longer versions. |
I prefer the syntax proposed by @whatthejeff. |
@fabian Do you want to implement these suggestions? Otherwise I can? |
Yes, already started, didn't find the time to finish though: https://github.com/fabian/phpunit-mock-objects/commits/willReturn Would love to get some feedback before I create a PR. |
Closing in favor of #147. |
Enable use of will('something') instead of will($this->returnValue('something'))