namespace foo;
use phpmock\Mock;
$time = new Mock(
__NAMESPACE__,
"time",
function () {
return 3;
}
);
$time->enable();
assert (3 == time());
$time->disable();
assert (3 != time());
显示文件
Open project: php-mock/php-mock
Class Usage Examples
Method | Description | |
---|---|---|
__construct ( string $namespace, string $name, callable $function ) | Set the namespace, function name and the mock function. | |
call ( array $arguments ) : mixed | Calls the mocked function. | |
define ( ) | Defines the mocked function in the given namespace. | |
disable ( ) | Disable this mock. | |
disableAll ( ) | Disable all mocks. | |
enable ( ) | Enables this mock. | |
getFQFN ( ) : string | Returns the fully qualified function name. | |
getName ( ) : string | Returns the unqualified function name. | |
getNamespace ( ) : string | Returns the namespace without enclosing slashes. |
public define ( ) |
public getNamespace ( ) : string | ||
return | string | The namespace |