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);
파일 보기
프로젝트 열기: php-mock/php-mock
1 사용 예제들
메소드 | 설명 | |
---|---|---|
__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 ( ) : |
||
리턴 | The recorded function arguments. |