39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\Coupon;
|
|
|
|
use Domain\Models\ValueObjects\Coupon\CouponQuantity;
|
|
|
|
covers(CouponQuantity::class);
|
|
|
|
describe('coupon quantity', function (): void {
|
|
it('creates a valid coupon quantity', function (): void {
|
|
// GIVEN
|
|
$quantity = 10;
|
|
|
|
// WHEN
|
|
$couponQuantity = new CouponQuantity($quantity);
|
|
|
|
// THEN
|
|
expect($couponQuantity)->toBeInstanceOf(CouponQuantity::class)
|
|
->and($couponQuantity->quantity)->toBe($quantity);
|
|
});
|
|
|
|
it('rejects a quantity of zero', function (): void {
|
|
// WHEN
|
|
$action = fn (): CouponQuantity => new CouponQuantity(0);
|
|
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'CouponQuantity quantity must be positive.');
|
|
});
|
|
|
|
it('rejects a negative quantity', function (): void {
|
|
// WHEN
|
|
$action = fn (): CouponQuantity => new CouponQuantity(-1);
|
|
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'CouponQuantity quantity must be positive.');
|
|
});
|
|
});
|