On this page
Sleep
class Sleep (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
static array | $fakeSleepCallbacks | The fake sleep callbacks. |
|
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
static void | macro(string $name, object|callable $macro) Register a custom macro. |
from Macroable |
static void | mixin(object $mixin, bool $replace = true) Mix another object into the class. |
from Macroable |
static bool | hasMacro(string $name) Checks if macro is registered. |
from Macroable |
static void | flushMacros() Flush the existing macros. |
from Macroable |
static mixed | __callStatic(string $method, array $parameters) Dynamically handle calls to the class. |
from Macroable |
mixed | __call(string $method, array $parameters) Dynamically handle calls to the class. |
from Macroable |
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 $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. |
|
$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. |
|
int|float | pullPending() Resolve the pending duration. |
|
static void | fake(bool $value = true) 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. |
|
$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. |
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 $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)
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.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/10.x/Illuminate/Support/Sleep.html