2026-09-22 16:29:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\CampaignRequest;
|
|
|
|
|
|
|
|
|
|
use Domain\Models\ValueObjects\CampaignRequest\RejectionReason;
|
|
|
|
|
|
|
|
|
|
covers(RejectionReason::class);
|
|
|
|
|
|
|
|
|
|
describe('rejection reason', function (): void {
|
2026-10-12 17:08:07 +02:00
|
|
|
$value = 'Missing legal documents.';
|
2026-09-22 16:29:34 +02:00
|
|
|
|
2026-10-12 17:08:07 +02:00
|
|
|
it('creates a valid rejection reason', function () use ($value): void {
|
2026-10-01 12:04:26 +02:00
|
|
|
// GIVEN / WHEN
|
2026-10-12 17:08:07 +02:00
|
|
|
$reason = new RejectionReason($value);
|
2026-09-22 16:29:34 +02:00
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($reason)->toBeInstanceOf(RejectionReason::class)
|
2026-10-12 17:08:07 +02:00
|
|
|
->and($reason->value)->toBe($value);
|
2026-09-22 16:29:34 +02:00
|
|
|
});
|
|
|
|
|
|
2026-10-12 17:08:07 +02:00
|
|
|
it('rejects an empty or whitespace-only reason', function (string $invalidValue): void {
|
2026-09-22 16:29:34 +02:00
|
|
|
// WHEN
|
2026-10-12 17:08:07 +02:00
|
|
|
$action = fn (): RejectionReason => new RejectionReason($invalidValue);
|
2026-09-22 16:29:34 +02:00
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($action)->toThrow(\DomainException::class, 'Rejection reason cannot be empty.');
|
|
|
|
|
})->with([
|
|
|
|
|
'empty' => '',
|
|
|
|
|
'spaces' => ' ',
|
|
|
|
|
]);
|
|
|
|
|
});
|