34 lines
880 B
PHP
34 lines
880 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
|
use DateTime;
|
|
|
|
covers(CouponValidity::class);
|
|
|
|
describe('coupon validity', function (): void {
|
|
it('creates a valid coupon validity', function (): void {
|
|
// GIVEN
|
|
$days = 30;
|
|
$until = new DateTime('2026-11-30');
|
|
|
|
// WHEN
|
|
$couponValidity = new CouponValidity($days, $until);
|
|
|
|
// THEN
|
|
expect($couponValidity->days)->toBe($days)
|
|
->and($couponValidity->until)->toBe($until);
|
|
});
|
|
|
|
it('rejects invalid coupon validity', function (): void {
|
|
// GIVEN
|
|
$days = 0;
|
|
$until = new DateTime('2026-11-30');
|
|
|
|
// GIVEN / THEN
|
|
expect(fn (): CouponValidity => new CouponValidity($days, $until))->toThrow(\DomainException::class);
|
|
});
|
|
});
|