PHP 클래스 phpmock\spy\Spy

If you create a Spy without a mock function, it will use the existing function. Example: 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);
저자: Markus Malkusch ([email protected])
상속: extends phpmock\Mock
파일 보기 프로젝트 열기: php-mock/php-mock 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( string $namespace, string $name, callable $function = null ) Initializes the spy.
call ( array $arguments )
getInvocations ( ) : Invocation[] Returns the recorded function calls and its arguments.

메소드 상세

__construct() 공개 메소드

If no function is specified it will use the existing function.
public __construct ( string $namespace, string $name, callable $function = null )
$namespace string The namespace for the mock function.
$name string The function name of the mocked function.
$function callable The mock function, or null for using the existing function.

call() 공개 메소드

public call ( array $arguments )
$arguments array

getInvocations() 공개 메소드

Returns the recorded function calls and its arguments.
public getInvocations ( ) : Invocation[]
리턴 Invocation[] The recorded function arguments.