ClockSensitiveTrait
Helps with mocking the time in your test cases.
This trait provides one self::mockTime() method that freezes the time. It restores the global clock after each test case. self::mockTime() accepts either a string (eg '+1 days' or '2022-12-22'), a DateTimeImmutable, or a boolean (to freeze/restore the global clock).
Tags
Table of Contents
Methods
Methods
mockTime()
public
static mockTime([string|DateTimeImmutable|bool $when = true ]) : ClockInterface
Parameters
- $when : string|DateTimeImmutable|bool = true