Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
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 | pest()->group('integration'); |
| 11 | |
| 12 | use Phexium\Plugin\Clock\Adapter\SystemClock; |
| 13 | |
| 14 | describe('Time retrieval', function (): void { |
| 15 | it('returns current date', function (): void { |
| 16 | $clock = new SystemClock(); |
| 17 | |
| 18 | $result = $clock->now(); |
| 19 | |
| 20 | expect($result)->toBeInstanceOf(DateTimeImmutable::class); |
| 21 | }); |
| 22 | |
| 23 | it('returns different dates on each call', function (): void { |
| 24 | $clock = new SystemClock(); |
| 25 | |
| 26 | $firstCall = $clock->now(); |
| 27 | usleep(1000); // Wait 1ms to ensure different timestamps |
| 28 | $secondCall = $clock->now(); |
| 29 | |
| 30 | expect($firstCall)->not->toEqual($secondCall); |
| 31 | }); |
| 32 | }); |