In PHPUnit, is there any difference between
$mockFoo->method('methodName')->will($this->returnValue($mockBar));
and
$mockFoo->method('methodName')->willReturn($mockBar);
No, willReturn()
is just a shortcut. Before it was introduced, the other variation was the only one. Now you don't need it for this simple case.
To quote the manual:
This short syntax is the same as
will($this->returnValue($value))
. We can use variations on this longer syntax to achieve more complex stubbing behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With