2026-09-22 12:45:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-09-29 17:12:16 +02:00
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\Coupon;
|
2026-09-22 12:45:08 +02:00
|
|
|
|
2026-09-25 16:21:20 +02:00
|
|
|
use Shared\Enums\Country;
|
2026-09-22 12:45:08 +02:00
|
|
|
use Domain\Models\ValueObjects\Coupon\CouponLegalInformation;
|
|
|
|
|
|
|
|
|
|
covers(CouponLegalInformation::class);
|
|
|
|
|
|
|
|
|
|
describe('coupon legal information', function (): void {
|
2026-10-12 17:08:07 +02:00
|
|
|
$legalText = 'Lorem ipsum dolor sit amet consectetur adipiscing elit.';
|
|
|
|
|
$emptyLegalText = '';
|
|
|
|
|
$forLocale = Country::FRANCE;
|
|
|
|
|
|
|
|
|
|
it('creates a valid coupon legal information FRANCE', function () use ($legalText, $forLocale): void {
|
|
|
|
|
// GIVEN / WHEN
|
|
|
|
|
$couponLegalInformation = new CouponLegalInformation(
|
|
|
|
|
$legalText,
|
|
|
|
|
$forLocale,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($couponLegalInformation->legalText)->toBe($legalText)
|
|
|
|
|
->and($couponLegalInformation->forLocale)->toBe($forLocale);
|
2026-10-01 12:04:26 +02:00
|
|
|
});
|
2026-09-22 12:45:08 +02:00
|
|
|
|
2026-10-12 17:08:07 +02:00
|
|
|
it('creates a valid coupon legal information BENELUX', function () use ($legalText): void {
|
2026-10-01 12:04:26 +02:00
|
|
|
// GIVEN / WHEN
|
|
|
|
|
$couponLegalInformation = new CouponLegalInformation(
|
2026-10-12 17:08:07 +02:00
|
|
|
$legalText,
|
|
|
|
|
Country::BENELUX,
|
2026-10-01 12:04:26 +02:00
|
|
|
);
|
2026-09-22 12:45:08 +02:00
|
|
|
|
|
|
|
|
// THEN
|
2026-10-12 17:08:07 +02:00
|
|
|
expect($couponLegalInformation->legalText)->toBe($legalText)
|
|
|
|
|
->and($couponLegalInformation->forLocale)->toBe(Country::BENELUX);
|
2026-09-22 12:45:08 +02:00
|
|
|
});
|
|
|
|
|
|
2026-10-12 17:08:07 +02:00
|
|
|
it('rejects invalid coupon legal information', function () use ($emptyLegalText, $forLocale): void {
|
2026-10-01 12:04:26 +02:00
|
|
|
// GIVEN / WHEN / THEN
|
|
|
|
|
expect(fn (): CouponLegalInformation => new CouponLegalInformation(
|
2026-10-12 17:08:07 +02:00
|
|
|
$emptyLegalText,
|
|
|
|
|
$forLocale,
|
2026-10-01 12:04:26 +02:00
|
|
|
))->toThrow(\DomainException::class);
|
2026-09-22 12:45:08 +02:00
|
|
|
});
|
|
|
|
|
});
|