47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\Campaign;
|
|
|
|
use Domain\Models\ValueObjects\Campaign\CampaignCoupon;
|
|
use Domain\Models\ValueObjects\PrintRules;
|
|
use Domain\Models\ValueObjects\ProcessingCode;
|
|
use Domain\Models\ValueObjects\Stock\StockId;
|
|
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
|
|
|
covers(CampaignCoupon::class);
|
|
|
|
describe('campaign coupon', function (): void {
|
|
it('creates a valid campaign coupon', function (): void {
|
|
// GIVEN
|
|
$code = new ProcessingCode('PC1');
|
|
$qty = StockId::generate();
|
|
$printRules = new PrintRules(maxPerCustomer: 3);
|
|
$warningThresholdQty = new WarningThresholdQuantity(100);
|
|
|
|
// WHEN
|
|
$campaignCoupon = new CampaignCoupon($code, $qty, $warningThresholdQty, $printRules);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->code)->toBe($code)
|
|
->and($campaignCoupon->qty)->toBe($qty)
|
|
->and($campaignCoupon->printRules)->toBe($printRules)
|
|
->and($campaignCoupon->warningThresholdQty)->toBe($warningThresholdQty);
|
|
});
|
|
|
|
it('creates a valid campaign coupon whitout print rules', function (): void {
|
|
// GIVEN
|
|
$code = new ProcessingCode('PC1');
|
|
$qty = StockId::generate();
|
|
$warningThresholdQty = new WarningThresholdQuantity(100);
|
|
|
|
// WHEN
|
|
$campaignCoupon = new CampaignCoupon($code, $qty, $warningThresholdQty);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->code)->toBe($code)
|
|
->and($campaignCoupon->qty)->toBe($qty)
|
|
->and($campaignCoupon->warningThresholdQty)->toBe($warningThresholdQty);
|
|
});
|
|
});
|