namespace foo;
use phpmock\environment\SleepEnvironmentBuilder;
$builder = new SleepEnvironmentBuilder();
$builder->addNamespace(__NAMESPACE__)
->setTimestamp(1417011228);
$environment = $builder->build();
$environment->enable();
This won't delay the test for 10 seconds, but increase time().
sleep(10);
assert(1417011228 + 10 == time());
Now revert the effect so that sleep() and time() are not mocked anymore.
$environment->disable();
ファイルを表示
Open project: php-mock/php-mock
Class Usage Examples
Method | Description | |
---|---|---|
addNamespace ( string $namespace ) : |
Add a namespace for the mock environment. | |
build ( ) : |
Builds a sleep(), usleep(), date(), time() and microtime() mock environment. | |
setTimestamp ( mixed $timestamp ) : |
Sets the mocked timestamp. |
public addNamespace ( string $namespace ) : |
||
$namespace | string | A namespace for the mock environment. |
return |
public build ( ) : |
||
return |
public setTimestamp ( mixed $timestamp ) : |
||
$timestamp | mixed | The timestamp. |
return |