With the Sleep helper class, you can easily specify delays in seconds, milliseconds, or even until a specific time. In testing, you can fake sleep to avoid real delays and make assertions on timing.
Sleep::for(1)->second();
Sleep::for(2)->milliseconds();
Sleep::for(3)->microseconds();
// ...
// In testing
Sleep::fake();
Sleep::assertSequence([
Sleep::for(1)->second(),
Sleep::for(2)->milliseconds(),
Sleep::for(3)->microseconds(),
]);
Sleep::assertSleptTimes(3);
|