Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | use Phexium\Plugin\Clock\Adapter\SystemClock; |
| 11 | |
| 12 | test('Should return current date', function (): void { |
| 13 | $clock = new SystemClock(); |
| 14 | |
| 15 | $result = $clock->now(); |
| 16 | |
| 17 | expect($result)->toBeInstanceOf(DateTimeImmutable::class); |
| 18 | }); |
| 19 | |
| 20 | test('Should return different dates on each call', function (): void { |
| 21 | $clock = new SystemClock(); |
| 22 | |
| 23 | $firstCall = $clock->now(); |
| 24 | usleep(1000); // Wait 1ms to ensure different timestamps |
| 25 | $secondCall = $clock->now(); |
| 26 | |
| 27 | expect($firstCall)->not->toEqual($secondCall); |
| 28 | }); |