PHP 클래스 phpmock\environment\SleepEnvironmentBuilder

In this environment sleep() and usleep() don't sleep for real. Instead they return immediatly and increase the amount of time in the mocks for date(), time() and microtime(). Example: 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();
저자: Markus Malkusch ([email protected])
파일 보기 프로젝트 열기: php-mock/php-mock 1 사용 예제들

공개 메소드들

메소드 설명
addNamespace ( string $namespace ) : SleepEnvironmentBuilder Add a namespace for the mock environment.
build ( ) : MockEnvironment Builds a sleep(), usleep(), date(), time() and microtime() mock environment.
setTimestamp ( mixed $timestamp ) : SleepEnvironmentBuilder Sets the mocked timestamp.

메소드 상세

addNamespace() 공개 메소드

Add a namespace for the mock environment.
public addNamespace ( string $namespace ) : SleepEnvironmentBuilder
$namespace string A namespace for the mock environment.
리턴 SleepEnvironmentBuilder

build() 공개 메소드

Builds a sleep(), usleep(), date(), time() and microtime() mock environment.
public build ( ) : MockEnvironment
리턴 MockEnvironment

setTimestamp() 공개 메소드

If not set the mock will use the current time at creation time. The timestamp can be an int, a float with microseconds or a string in the microtime() format.
public setTimestamp ( mixed $timestamp ) : SleepEnvironmentBuilder
$timestamp mixed The timestamp.
리턴 SleepEnvironmentBuilder