38 lines
993 B
PHP
38 lines
993 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 {
|
|
beforeEach(function (): void {
|
|
$this->days = 30;
|
|
$this->zeroDays = 0;
|
|
$this->until = new DateTime('2026-11-30');
|
|
});
|
|
|
|
it('creates a valid coupon validity', function (): void {
|
|
// GIVEN / WHEN
|
|
$couponValidity = new CouponValidity(
|
|
$this->days,
|
|
$this->until
|
|
);
|
|
|
|
// THEN
|
|
expect($couponValidity->days)->toBe($this->days)
|
|
->and($couponValidity->until)->toBe($this->until);
|
|
});
|
|
|
|
it('rejects invalid coupon validity', function (): void {
|
|
// GIVEN / WHEN / THEN
|
|
expect(fn (): CouponValidity => new CouponValidity(
|
|
$this->zeroDays,
|
|
$this->until
|
|
))->toThrow(\DomainException::class);
|
|
});
|
|
});
|