Add comprehensive unit tests to validate the behavior of various value objects.
28 lines
723 B
PHP
28 lines
723 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
use Domain\Models\ValueObjects\BrandCode;
|
|
|
|
covers(BrandCode::class);
|
|
|
|
describe('BrandCode Value Object', function (): void {
|
|
it('accepts valid positive brand codes', function (int $input): void {
|
|
// GIVEN
|
|
$value = $input;
|
|
|
|
// WHEN
|
|
$brandCode = new BrandCode($value);
|
|
|
|
// THEN
|
|
expect($brandCode->value)->toBe($value);
|
|
})->with([13, 1, 9999]);
|
|
|
|
it('rejects zero or negative brand codes', function (int $invalid): void {
|
|
// GIVEN / WHEN / THEN
|
|
expect(fn () => new BrandCode($invalid))
|
|
->toThrow(\DomainException::class);
|
|
})->with([0, -1, -9999]);
|
|
});
|