94 lines
3.8 KiB
PHP
94 lines
3.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects\Campaign;
|
|
|
|
use Domain\Models\ValueObjects\Campaign\CampaignCoupon;
|
|
use Domain\Models\ValueObjects\Coupon\CouponQuantity;
|
|
use Domain\Models\ValueObjects\PrintRules;
|
|
use Domain\Models\ValueObjects\ProcessingCode;
|
|
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
|
use Shared\Enums\Country;
|
|
|
|
covers(CampaignCoupon::class);
|
|
|
|
describe('campaign coupon', function (): void {
|
|
it('creates a valid campaign coupon', function (): void {
|
|
// GIVEN
|
|
$processingCode = new ProcessingCode('PC1');
|
|
$quantity = new CouponQuantity(10);
|
|
$availableIn = Country::FRANCE;
|
|
$warningThresholdQuantity = new WarningThresholdQuantity(100);
|
|
$printRules = new PrintRules(maxPerCustomer: 3);
|
|
|
|
// WHEN
|
|
$campaignCoupon = new CampaignCoupon($processingCode, $quantity, $availableIn, $warningThresholdQuantity, $printRules);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($availableIn)
|
|
->and($campaignCoupon->warningThresholdQuantity)->toBe($warningThresholdQuantity)
|
|
->and($campaignCoupon->printRules)->toBe($printRules);
|
|
});
|
|
|
|
it('creates a valid campaign coupon whitout warning threshold quantity', function (): void {
|
|
// GIVEN
|
|
$processingCode = new ProcessingCode('PC1');
|
|
$quantity = new CouponQuantity(10);
|
|
$availableIn = Country::FRANCE;
|
|
$printRules = new PrintRules(maxPerCustomer: 3);
|
|
|
|
// WHEN
|
|
$campaignCoupon = new CampaignCoupon(
|
|
processingCode: $processingCode,
|
|
quantity: $quantity,
|
|
availableIn: $availableIn,
|
|
printRules: $printRules
|
|
);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($availableIn)
|
|
->and($campaignCoupon->printRules)->toBe($printRules);
|
|
});
|
|
|
|
it('creates a valid campaign coupon whitout print rules', function (): void {
|
|
// GIVEN
|
|
$processingCode = new ProcessingCode('PC1');
|
|
$quantity = new CouponQuantity(10);
|
|
$availableIn = Country::FRANCE;
|
|
$warningThresholdQuantity = new WarningThresholdQuantity(100);
|
|
|
|
// WHEN
|
|
$campaignCoupon = new CampaignCoupon(
|
|
processingCode: $processingCode,
|
|
quantity: $quantity,
|
|
availableIn: $availableIn,
|
|
warningThresholdQuantity: $warningThresholdQuantity
|
|
);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($availableIn)
|
|
->and($campaignCoupon->warningThresholdQuantity)->toBe($warningThresholdQuantity);
|
|
});
|
|
|
|
it('creates a valid campaign coupon whitout warning threshold quantity and print rules', function (): void {
|
|
// GIVEN
|
|
$processingCode = new ProcessingCode('PC1');
|
|
$quantity = new CouponQuantity(10);
|
|
$availableIn = Country::FRANCE;
|
|
|
|
// WHEN
|
|
$campaignCoupon = new CampaignCoupon(processingCode: $processingCode, quantity: $quantity, availableIn: $availableIn);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($availableIn);
|
|
});
|
|
});
|