82 lines
3 KiB
PHP
82 lines
3 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 Shared\Enums\Country;
|
|
|
|
covers(CampaignCoupon::class);
|
|
|
|
describe('campaign coupon', function (): void {
|
|
beforeEach(function (): void {
|
|
$this->processingCode = new ProcessingCode('PC1');
|
|
$this->quantity = new CouponQuantity(10);
|
|
$this->availableIn = Country::FRANCE;
|
|
$this->printRules = new PrintRules(maxPerCustomer: 3);
|
|
});
|
|
|
|
it('creates a valid campaign coupon', function (): void {
|
|
// GIVEN / WHEN
|
|
$campaignCoupon = new CampaignCoupon(
|
|
$this->processingCode,
|
|
$this->quantity,
|
|
$this->availableIn,
|
|
$this->printRules
|
|
);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($this->processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($this->quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($this->availableIn)
|
|
->and($campaignCoupon->printRules)->toBe($this->printRules);
|
|
});
|
|
|
|
it('creates a valid campaign coupon whitout warning threshold quantity', function (): void {
|
|
// GIVEN / WHEN
|
|
$campaignCoupon = new CampaignCoupon(
|
|
processingCode: $this->processingCode,
|
|
quantity: $this->quantity,
|
|
availableIn: $this->availableIn,
|
|
printRules: $this->printRules
|
|
);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($this->processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($this->quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($this->availableIn)
|
|
->and($campaignCoupon->printRules)->toBe($this->printRules);
|
|
});
|
|
|
|
it('creates a valid campaign coupon whitout print rules', function (): void {
|
|
// GIVEN / WHEN
|
|
$campaignCoupon = new CampaignCoupon(
|
|
processingCode: $this->processingCode,
|
|
quantity: $this->quantity,
|
|
availableIn: $this->availableIn,
|
|
);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($this->processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($this->quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($this->availableIn);
|
|
});
|
|
|
|
it('creates a valid campaign coupon whitout warning threshold quantity and print rules', function (): void {
|
|
// GIVEN / WHEN
|
|
$campaignCoupon = new CampaignCoupon(
|
|
processingCode: $this->processingCode,
|
|
quantity: $this->quantity,
|
|
availableIn: $this->availableIn
|
|
);
|
|
|
|
// THEN
|
|
expect($campaignCoupon->processingCode)->toBe($this->processingCode)
|
|
->and($campaignCoupon->quantity)->toBe($this->quantity)
|
|
->and($campaignCoupon->availableIn)->toBe($this->availableIn);
|
|
});
|
|
});
|