Add comprehensive unit tests to validate the behavior of various value objects.
28 lines
756 B
PHP
28 lines
756 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
use Domain\Models\ValueObjects\ServiceId;
|
|
|
|
covers(ServiceId::class);
|
|
|
|
describe('ServiceId Value Object', function (): void {
|
|
it('accepts valid numeric service identifiers', function (string $input): void {
|
|
// GIVEN
|
|
$value = $input;
|
|
|
|
// WHEN
|
|
$vo = new ServiceId($value);
|
|
|
|
// THEN
|
|
expect($vo->value)->toBe($value);
|
|
})->with(['097', '1', '12345']);
|
|
|
|
it('rejects non-numeric service identifiers', function (string $invalid): void {
|
|
// GIVEN / WHEN / THEN
|
|
expect(fn () => new ServiceId($invalid))
|
|
->toThrow(\DomainException::class);
|
|
})->with(['SERV01', 'abc', '', ' 097 ', '-10']);
|
|
});
|