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();
파일 보기
프로젝트 열기: php-mock/php-mock
1 사용 예제들
메소드 | 설명 | |
---|---|---|
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. |
리턴 |