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
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.