Sleep
class Sleep (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
static array | $fakeSleepCallbacks | The fake sleep callbacks. |
|
static protected bool | $syncWithCarbon | Keep Carbon's "now" in sync when sleeping. |
|
CarbonInterval | $duration | The total duration to sleep. |
|
Closure | $while | The callback that determines if sleeping should continue. |
|
protected int|float|null | $pending | The pending duration to sleep. |
|
static protected bool | $fake | Indicates that all sleeping should be faked. |
|
static protected CarbonInterval> | $sequence | The sequence of sleep durations encountered while faking. |
|
protected bool | $shouldSleep | Indicates if the instance should sleep. |
|
protected bool | $alreadySlept | Indicates if the instance already slept via |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Sleep for the given duration. Replaces any previously defined duration.
Sleep for the given number of minutes.
Sleep for one minute.
Sleep for the given number of seconds.
Sleep for one second.
Sleep for the given number of milliseconds.
Sleep for one millisecond.
Sleep for the given number of microseconds.
Sleep for on microsecond.
Add additional time to sleep for.
Specify a callback that should be executed after sleeping.
Handle the object's destruction.
Handle the object's destruction.
Resolve the pending duration.
Stay awake and capture any attempts to sleep.
Assert a given amount of sleeping occurred a specific number of times.
Assert sleeping occurred a given number of times.
Assert the given sleep sequence was encountered.
Assert that no sleeping occurred.
Assert that no sleeping occurred.
Indicate that the instance should not sleep.
Only sleep when the given condition is true.
Don't sleep when the given condition is true.
Specify a callback that should be invoked when faking sleep within a test.
Indicate that Carbon's "now" should be kept in sync when sleeping.
Details
static Sleep
until(DateTimeInterface|int|float|numeric-string $timestamp)
Sleep until the given timestamp.
protected $this
duration(DateInterval|int|float $duration)
Sleep for the given duration. Replaces any previously defined duration.
static void
fake(bool $value = true, bool $syncWithCarbon = false)
Stay awake and capture any attempts to sleep.
static void
assertSlept(Closure $expected, int $times = 1)
Assert a given amount of sleeping occurred a specific number of times.
static void
whenFakingSleep(callable $callback)
Specify a callback that should be invoked when faking sleep within a test.