Class SleepEnvironmentBuilder
Builds a sleep(), usleep(), date(), time() and microtime() mock environment.
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();
Namespace: phpmock\environment
License: WTFPL
Author: Markus Malkusch markus@malkusch.de
Link: Donations
Located at environment/SleepEnvironmentBuilder.php
Methods summary
License: WTFPL
Author: Markus Malkusch markus@malkusch.de
Link: Donations
Located at environment/SleepEnvironmentBuilder.php
public
phpmock\environment\SleepEnvironmentBuilder
#
addNamespace( string $namespace )
Add a namespace for the mock environment.
Add a namespace for the mock environment.
Parameters
- $namespace
- A namespace for the mock environment.
Returns
public
phpmock\environment\SleepEnvironmentBuilder
#
setTimestamp( mixed $timestamp )
Sets the mocked timestamp.
Sets the mocked timestamp.
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.
Parameters
- $timestamp
- The timestamp.
Returns
public
phpmock\environment\MockEnvironment