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