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. |
|
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. |
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.
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 void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool
hasMacro(string $name)
Checks if macro is registered.
static void
flushMacros()
Flush the existing macros.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
void
__construct(int|float|DateInterval $duration)
Create a new class instance.
static Sleep
for(DateInterval|int|float $duration)
Sleep for the given duration.
static Sleep
until(DateTimeInterface|int|float|numeric-string $timestamp)
Sleep until the given timestamp.
static Sleep
usleep(int $duration)
Sleep for the given number of microseconds.
static Sleep
sleep(int|float $duration)
Sleep for the given number of seconds.
protected $this
duration(DateInterval|int|float $duration)
Sleep for the given duration. Replaces any previously defined duration.
$this
minutes()
Sleep for the given number of minutes.
$this
minute()
Sleep for one minute.
$this
seconds()
Sleep for the given number of seconds.
$this
second()
Sleep for one second.
$this
milliseconds()
Sleep for the given number of milliseconds.
$this
millisecond()
Sleep for one millisecond.
$this
microseconds()
Sleep for the given number of microseconds.
$this
microsecond()
Sleep for on microsecond.
$this
and(int|float $duration)
Add additional time to sleep for.
void
__destruct()
Handle the object's destruction.
protected int|float
pullPending()
Resolve the pending 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
assertSleptTimes(int $expected)
Assert sleeping occurred a given number of times.
static void
assertSequence(array $sequence)
Assert the given sleep sequence was encountered.
static void
assertNeverSlept()
Assert that no sleeping occurred.
static void
assertInsomniac()
Assert that no sleeping occurred.
protected $this
shouldNotSleep()
Indicate that the instance should not sleep.
$this
when($condition)
Only sleep when the given condition is true.
$this
unless($condition)
Don't sleep when the given condition is true.
static void
whenFakingSleep(callable $callback)
Specify a callback that should be invoked when faking sleep within a test.
static void
syncWithCarbon($value = true)
Indicate that Carbon's "now" should be kept in sync when sleeping.