namespace foo;
use phpmock\spy\Spy;
function bar($min, $max) {
return rand($min, $max) + 3;
}
$spy = new Spy(__NAMESPACE__, "rand");
$spy->enable();
$result = bar(1, 2);
assert ([1, 2] == $spy->getInvocations()[0]->getArguments());
assert ($result == $spy->getInvocations()[0]->getReturn() + 3);
ファイルを表示
Open project: php-mock/php-mock
Class Usage Examples
Method | Description | |
---|---|---|
__construct ( string $namespace, string $name, callable $function = null ) | Initializes the spy. | |
call ( array $arguments ) | ||
getInvocations ( ) : |
Returns the recorded function calls and its arguments. |
public getInvocations ( ) : |
||
return | The recorded function arguments. |