Skip to content

Commit

Permalink
Document capturing arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccreary committed Nov 19, 2019
1 parent 97a4f7e commit b4fce4b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/reference/argument_validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,27 @@ methods to call.

There is no Hamcrest version of the ``ducktype()`` matcher.

Capturing Arguments
-------------------

If we want to perform multiple validations on a single argument, the ``capture``
matcher provides a streamlined alternative to using the ``on()`` matcher.
It accepts a variable which the actual argument will be assigned.

.. code-block:: php
$mock = \Mockery::mock('MyClass');
$mock->shouldReceive("foo")
->with(\Mockery::capture($bar));
This will assign *any* argument passed to ``foo`` to the local ``$bar`` variable to
then perform additional validation using assertions.

.. note::

The ``capture`` matcher always evaluates to ``true``. As such, we should always
perform additional argument validation.

Additional Argument Matchers
----------------------------

Expand Down

0 comments on commit b4fce4b

Please sign in to comment.