ldc-cocotte/tests/Unit/Domain/Models/ValueObjects/Entities/OrderIdTest.php

28 lines
708 B
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain\Models\ValueObjects\Entities;
use Domain\Models\ValueObjects\Entities\OrderId;
use Shared\Helpers\UuidHelper;
describe('OrderId', function (): void {
it('can be instantiated with uuid v7', function (): void {
// GIVEN
$uuid = UuidHelper::v7();
// WHEN
$id = new OrderId($uuid);
// THEN
expect($id->value)->toBe($uuid);
});
it('throws exception with non v7 uuid', function (): void {
// GIVEN
$uuid = UuidHelper::v4();
// WHEN
$action = fn () => new OrderId($uuid);
// THEN
expect($action)->toThrow(\DomainException::class);
});
});