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