Skip to content

Commit a903744

Browse files
Merge branch '7.5' into 8.5
2 parents 55f5113 + 7e601e0 commit a903744

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/test-doubles.rst

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,32 @@ the same best practice defaults used by ``createStub()``.
182182
}
183183
184184
In the examples so far we have been returning simple values using
185-
``willReturn($value)``. This short syntax is the same as
186-
``will($this->returnValue($value))``. We can use variations
187-
on this longer syntax to achieve more complex stubbing behaviour.
185+
``willReturn($value)`` – a short syntax for convenience. :numref:`test-doubles.stubs.shorthands` shows the
186+
available stubbing short hands alongside their longer counterparts.
187+
188+
.. rst-class:: table
189+
.. list-table:: Stubbing short hands
190+
:name: test-doubles.stubs.shorthands
191+
:header-rows: 1
192+
193+
* - short hand
194+
- longer syntax
195+
* - ``willReturn($value)``
196+
- ``will($this->returnValue($value))``
197+
* - ``willReturnArgument($argumentIndex)``
198+
- ``will($this->returnArgument($argumentIndex))``
199+
* - ``willReturnCallback($callback)``
200+
- ``will($this->returnCallback($callback))``
201+
* - ``willReturnMap($valueMap)``
202+
- ``will($this->returnValueMap($valueMap))``
203+
* - ``willReturnOnConsecutiveCalls($value1, $value2)``
204+
- ``will($this->onConsecutiveCalls($value1, $value2))``
205+
* - ``willReturnSelf()``
206+
- ``will($this->returnSelf())``
207+
* - ``willThrowException($exception)``
208+
- ``will($this->throwException($exception))``
209+
210+
We can use variations on this longer syntax to achieve more complex stubbing behaviour.
188211

189212
Sometimes you want to return one of the arguments of a method call
190213
(unchanged) as the result of a stubbed method call.

0 commit comments

Comments
 (0)