__construct()
__construct(\PHPUnit_Framework_TestCase $test, \Shmock\Instance $shmock, string $method, array $with, bool $order_matters, int $call_index)
This class is not directly instantiated, but instead returned every time you invoke a method on a \Shmock\Instance or \Shmock\StaticClass.
Specs in Shmock make the assumption that because you are mocking the method that it will
be invoked at least once. This is a default setting on the mock and can be changed by
specifying a number of times to invoke the method, as done above with the twice()
method.
Callers intending to invoke methods more than once with different arguments are directed to
the return_value_map
facility or to specify $mock->order_matters();
.
A few options on specs can be in conflict with each other. For example, you may elect to
return a value to the caller via return_value($v)
, throw an exception via throw_exception($e)
or to perform a custom action via will(function () {})
. In cases of a conflict, last expectation
set wins.
PHPUnit specs also accept standar \PHPUnit_Framework_Constraint
instances as arguments,
so wildcard arguments or other helpers from PHPUnit are available for use:
$calc->add($this->greaterThan(1), $this->lessThan(2));
Parameters
\PHPUnit_Framework_TestCase | $test | |
\Shmock\Instance | $shmock | |
string | $method | |
array | $with | |
bool | $order_matters | |
int | $call_index |