refactor: ♻️ refactor coupon diffusion test

This commit is contained in:
Corentin Huet 2026-10-02 12:46:02 +02:00
parent 871ceade05
commit 678487aa07
2 changed files with 10 additions and 20 deletions

View file

@ -14,10 +14,10 @@ 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);
$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 {

View file

@ -11,25 +11,15 @@ use DateTime;
covers(CouponDiffusion::class);
describe('coupon diffusion', function (): void {
it('creates a valid coupon diffusion with one period', function (): void {
// GIVEN
$period = new Period(new DateTime('2026-01-01'), new DateTime('2026-02-01'));
// WHEN
$couponDiffusion = new CouponDiffusion($period);
// THEN
expect($couponDiffusion->period)->toBe($period);
beforeEach(function (): void {
$this->period = new Period(new DateTime('2026-01-01'), new DateTime('2026-02-01'));
});
it('creates a valid coupon diffusion with several periods', function (): void {
// GIVEN
$period = new Period(new DateTime('2026-01-01'), new DateTime('2026-02-01'));
// WHEN
$couponDiffusion = new CouponDiffusion($period);
it('creates a valid coupon diffusion with one period', function (): void {
// GIVEN / WHEN
$couponDiffusion = new CouponDiffusion($this->period);
// THEN
expect($couponDiffusion->period)->toBe($period);
expect($couponDiffusion->period)->toBe($this->period);
});
});