Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
21 / 21 |
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('unit'); |
| 11 | |
| 12 | use Phexium\Domain\Id\TimestampId; |
| 13 | |
| 14 | describe('Creation', function (): void { |
| 15 | it('creates from int and string', function (): void { |
| 16 | $fromInt = TimestampId::from(123); |
| 17 | $fromString = TimestampId::from('456'); |
| 18 | |
| 19 | expect($fromInt->getValue())->toBe(123) |
| 20 | ->and($fromString->getValue())->toBe(456) |
| 21 | ; |
| 22 | }); |
| 23 | }); |
| 24 | |
| 25 | describe('Equality', function (): void { |
| 26 | it('compares by value and converts to string', function (): void { |
| 27 | $id1 = TimestampId::from(100); |
| 28 | $id2 = TimestampId::from(100); |
| 29 | $id3 = TimestampId::from(200); |
| 30 | |
| 31 | expect((string) $id1)->toBe('100') |
| 32 | ->and($id1->equals($id2))->toBeTrue() |
| 33 | ->and($id1->equals($id3))->toBeFalse() |
| 34 | ; |
| 35 | }); |
| 36 | }); |