2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\Entities;
|
|
|
|
|
|
|
|
|
|
use Domain\Models\ValueObjects\Entities\BasketId;
|
2026-11-17 12:15:39 +01:00
|
|
|
use Shared\Helpers\UuidHelper;
|
2026-06-14 21:32:07 +02:00
|
|
|
|
|
|
|
|
describe('BasketId', function (): void {
|
|
|
|
|
it('can be instantiated with a Uuid', function (): void {
|
|
|
|
|
// GIVEN
|
2026-11-17 12:15:39 +01:00
|
|
|
$uuid = UuidHelper::v7();
|
2026-06-14 21:32:07 +02:00
|
|
|
// WHEN
|
|
|
|
|
$id = new BasketId($uuid);
|
|
|
|
|
// THEN
|
|
|
|
|
expect($id->value)->toBe($uuid);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws exception with non v7 uuid', function (): void {
|
|
|
|
|
// GIVEN
|
2026-11-17 12:15:39 +01:00
|
|
|
$uuid = UuidHelper::v4();
|
2026-06-14 21:32:07 +02:00
|
|
|
// WHEN
|
|
|
|
|
$action = fn () => new BasketId($uuid);
|
|
|
|
|
// THEN
|
|
|
|
|
expect($action)->toThrow(\DomainException::class);
|
|
|
|
|
});
|
|
|
|
|
});
|