Sleep
Uses
Properties
$fakeSleepCallbacks array
The fake sleep callbacks.
$duration Carbon\CarbonInterval
The total duration to sleep.
$pending int|float|null
The pending duration to sleep.
$fake bool
Indicates that all sleeping should be faked.
$sequence
array
The sequence of sleep durations encountered while faking.
$shouldSleep bool
Indicates if the instance should sleep.
Methods
__construct ( $duration ) : void
Create a new class instance.
Parameters
- $duration int|float|DateInterval
for ( $duration ) : static
Sleep for the given duration.
Parameters
- $duration DateInterval |int|float
until ( $timestamp ) : static
Sleep until the given timestamp.
Parameters
- $timestamp DateTimeInterface |int
usleep ( $duration ) : static
Sleep for the given number of microseconds.
Parameters
- $duration int
sleep ( $duration ) : static
Sleep for the given number of seconds.
Parameters
- $duration int|float
duration ( $duration ) : $this
Sleep for the given duration. Replaces any previously defined duration.
Parameters
- $duration DateInterval |int|float
minutes ( ) : $this
Sleep for the given number of minutes.
minute ( ) : $this
Sleep for one minute.
seconds ( ) : $this
Sleep for the given number of seconds.
second ( ) : $this
Sleep for one second.
milliseconds ( ) : $this
Sleep for the given number of milliseconds.
millisecond ( ) : $this
Sleep for one millisecond.
microseconds ( ) : $this
Sleep for the given number of microseconds.
microsecond ( ) : $this
Sleep for on microsecond.
and ( $duration ) : $this
Add additional time to sleep for.
Parameters
- $duration int|float
__destruct ( ) : void
Handle the object's destruction.
pullPending ( ) : int|float
Resolve the pending duration.
fake ( $value ) : void
Stay awake and capture any attempts to sleep.
Parameters
- $value bool
assertSlept ( $expected , $times ) : void
Assert a given amount of sleeping occurred a specific number of times.
Parameters
- $expected Closure
- $times int
assertSleptTimes ( $expected ) : void
Assert sleeping occurred a given number of times.
Parameters
- $expected int
assertSequence ( $sequence ) : void
Assert the given sleep sequence was encountered.
Parameters
- $sequence array
assertNeverSlept ( ) : void
Assert that no sleeping occurred.
assertInsomniac ( ) : void
Assert that no sleeping occurred.
shouldNotSleep ( ) : $this
Indicate that the instance should not sleep.
when ( $condition ) : $this
Only sleep when the given condition is true.
Parameters
- $condition callable|bool
unless ( $condition ) : $this
Don't sleep when the given condition is true.
Parameters
- $condition callable|bool
whenFakingSleep ( $callback ) : void
Specify a callback that should be invoked when faking sleep within a test.
Parameters
- $callback callable