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();
Показать файл
Открыть проект
Примеры использования класса
Метод | Описание | |
---|---|---|
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. |
Результат |
public build ( ) : |
||
Результат |
public setTimestamp ( mixed $timestamp ) : |
||
$timestamp | mixed | The timestamp. |
Результат |