diff --git a/src/Application/UseCases/Campaign/Transform/Input.php b/src/Application/UseCases/Campaign/Transform/Input.php index 7aec639..c4ca5dc 100644 --- a/src/Application/UseCases/Campaign/Transform/Input.php +++ b/src/Application/UseCases/Campaign/Transform/Input.php @@ -4,13 +4,56 @@ declare(strict_types=1); namespace Application\UseCases\Campaign\Transform; +use Domain\Models\ValueObjects\Campaign\CampaignCode; +use Domain\Models\ValueObjects\Campaign\CampaignName; use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestId; +use Domain\Models\ValueObjects\Coupon\CouponAvailabilityCalendar; +use Domain\Models\ValueObjects\Coupon\CouponCode; +use Domain\Models\ValueObjects\Coupon\CouponDiffusion; +use Domain\Models\ValueObjects\Coupon\CouponLegalInformation; +use Domain\Models\ValueObjects\Coupon\CouponQuantity; +use Domain\Models\ValueObjects\Coupon\CouponValidity; +use Domain\Models\ValueObjects\Coupon\CouponValidityInformation; +use Domain\Models\ValueObjects\CouponName; +use Domain\Models\ValueObjects\CouponPicture; +use Domain\Models\ValueObjects\GS1; +use Domain\Models\ValueObjects\IncoCode; +use Domain\Models\ValueObjects\MoneyAmount; +use Domain\Models\ValueObjects\PrintRules; +use Domain\Models\ValueObjects\ProcessingCode; +use Domain\Models\ValueObjects\WarningThresholdQuantity; use Shared\DDD\UseCases\Input as UseCaseInput; +use Shared\Enums\Country; final readonly class Input implements UseCaseInput { + /** + * @param array $couponValidityInformation + * @param array $couponLegalInformation + * @param array $availableIn + * @param array $products + */ public function __construct( public CampaignRequestId $id, + public CouponCode $couponCode, + public CouponName $couponName, + public MoneyAmount $amount, + public CouponPicture $picture, + public CouponDiffusion $diffusion, + public CouponValidity $validity, + public array $couponValidityInformation, + public array $couponLegalInformation, + public ProcessingCode $processingCode, + public CampaignCode $campaignCode, + public CampaignName $campaignName, + public bool $publication, + public CouponQuantity $quantity, + public array $availableIn, + public array $products = [], + public ?CouponAvailabilityCalendar $availabilityCalendar = null, + public ?GS1 $gs1 = null, + public ?WarningThresholdQuantity $warningThresholdQuantity = null, + public ?PrintRules $printRules = null, ) { } } diff --git a/src/Application/UseCases/CampaignRequest/Validate/Output/CampaignRequestNotFound.php b/src/Application/UseCases/Campaign/Transform/Output/CampaignRequestNotFound.php similarity index 61% rename from src/Application/UseCases/CampaignRequest/Validate/Output/CampaignRequestNotFound.php rename to src/Application/UseCases/Campaign/Transform/Output/CampaignRequestNotFound.php index e8f6500..102f049 100644 --- a/src/Application/UseCases/CampaignRequest/Validate/Output/CampaignRequestNotFound.php +++ b/src/Application/UseCases/Campaign/Transform/Output/CampaignRequestNotFound.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Application\UseCases\CampaignRequest\Validate\Output; +namespace Application\UseCases\Campaign\Transform\Output; final readonly class CampaignRequestNotFound implements Output { diff --git a/src/Application/UseCases/Campaign/Transform/Output/CampaignRequestTransformed.php b/src/Application/UseCases/Campaign/Transform/Output/CampaignRequestTransformed.php new file mode 100644 index 0000000..23fdd04 --- /dev/null +++ b/src/Application/UseCases/Campaign/Transform/Output/CampaignRequestTransformed.php @@ -0,0 +1,15 @@ + */ -final readonly class TransformCampaignRequest implements UseCase +/** @implements UseCase<\Application\UseCases\Campaign\Transform\Input, \Application\UseCases\Campaign\Transform\Output\Output> */ +final readonly class TransformCampaignRequest implements UseCase, Transactional { public function __construct( - private CampaignRequestRepository $campaignRequestRepository + private CampaignRequestRepository $campaignRequestRepository, + private CouponRepository $couponRepository, + private CampaignRepository $campaignRepository, ) {} #[\Override] @@ -35,22 +41,56 @@ final readonly class TransformCampaignRequest implements UseCase return new CampaignRequestNotFound(); } - $isGame = $campaignRequest->campaignType === CampaignRequestType::GAME; + // Use it early to check if this campaignRequest can be validated. + $campaignRequest = $campaignRequest->validate(); - // TODO: get the actuel ActorID + // TODO: get the actual ActorId $actorId = ActorId::generate(); - $campaignCreate = Campaign::create( - // TODO: use a true name generation - code: new CampaignCode("ddd"), - name: $campaignRequest->name, - publication: false, - printAllAtOnce: $isGame, - coupons: [], - // FIXME : ajout de coupons + $coupon = Coupon::create( + code: $input->couponCode, + name: $input->couponName, + amount: $input->amount, + picture: $input->picture, + diffusion: $input->diffusion, + validity: $input->validity, + couponValidityInformation: $input->couponValidityInformation, + couponLegalInformation: $input->couponLegalInformation, + processingCode: $input->processingCode, brandCode: $campaignRequest->brandCode, - actorId: $actorId + createdBy: $actorId, + products: $input->products, + availabilityCalendar: $input->availabilityCalendar, + gs1: $input->gs1, ); + $this->couponRepository->save($coupon); + $isGame = $campaignRequest->campaignType === CampaignRequestType::GAME; + + $campaign = Campaign::create( + code: $input->campaignCode, + name: $input->campaignName, + publication: $input->publication, + printAllAtOnce: $isGame, + coupons: [ + new CampaignCoupon( + processingCode: $coupon->processingCode, + quantity: $input->quantity, + availableIn: $input->availableIn, + warningThresholdQuantity: $input->warningThresholdQuantity, + printRules: $input->printRules, + ), + ], + brandCode: $campaignRequest->brandCode, + actorId: $actorId, + ); + $this->campaignRepository->save($campaign); + + $this->campaignRequestRepository->save($campaignRequest); + + + return new CampaignRequestTransformed( + campaign: $campaign, + ); } } diff --git a/src/Application/UseCases/CampaignRequest/Validate/Input.php b/src/Application/UseCases/CampaignRequest/Validate/Input.php deleted file mode 100644 index fda9e72..0000000 --- a/src/Application/UseCases/CampaignRequest/Validate/Input.php +++ /dev/null @@ -1,16 +0,0 @@ - */ -final readonly class ValidateCampaignRequest implements UseCase, Transactional -{ - public function __construct( - private CampaignRequestRepository $repository, - ) { - } - - #[\Override] - public function execute(BaseInput $input): Output - { - Assert::isInstanceOf($input, Input::class); - - $campaignRequest = $this->repository->findById($input->id); - - if (! $campaignRequest instanceof CampaignRequest) { - return new CampaignRequestNotFound(); - } - - // TODO: ici viendront les méthodes de création de campaign / coupon + leur association - $campaignRequest = $campaignRequest->validate(); - - $this->repository->save($campaignRequest); - - return new CampaignRequestValidated( - id: $campaignRequest->id(), - status: $campaignRequest->status, - updatedAt: $campaignRequest->updatedAt(), - ); - } -} diff --git a/src/Domain/Models/Entities/Coupon.php b/src/Domain/Models/Entities/Coupon.php index c3075f7..f879cd9 100644 --- a/src/Domain/Models/Entities/Coupon.php +++ b/src/Domain/Models/Entities/Coupon.php @@ -47,7 +47,7 @@ final readonly class Coupon implements AggregateRoot, HasTimestampIdentifier public ActorId $createdBy, public array $products = [], public ?CouponAvailabilityCalendar $availabilityCalendar = null, - public ?GS1 $gtin = null, + public ?GS1 $gs1 = null, public ?\DateTimeInterface $updatedAt = null, ) { foreach ($this->couponValidityInformation as $validityInformation) { @@ -97,7 +97,7 @@ final readonly class Coupon implements AggregateRoot, HasTimestampIdentifier ActorId $createdBy, array $products = [], ?CouponAvailabilityCalendar $availabilityCalendar = null, - ?GS1 $gtin = null, + ?GS1 $gs1 = null, ?\DateTimeInterface $updatedAt = null, ): Coupon { return new self( @@ -115,7 +115,7 @@ final readonly class Coupon implements AggregateRoot, HasTimestampIdentifier createdBy: $createdBy, products: $products, availabilityCalendar: $availabilityCalendar, - gtin: $gtin, + gs1: $gs1, updatedAt: $updatedAt, ); } @@ -140,7 +140,7 @@ final readonly class Coupon implements AggregateRoot, HasTimestampIdentifier ActorId $createdBy, array $products = [], ?CouponAvailabilityCalendar $availabilityCalendar = null, - ?GS1 $gtin = null, + ?GS1 $gs1 = null, ?\DateTimeInterface $updatedAt = null, ): self { return new self( @@ -158,7 +158,7 @@ final readonly class Coupon implements AggregateRoot, HasTimestampIdentifier createdBy: $createdBy, products: $products, availabilityCalendar: $availabilityCalendar, - gtin: $gtin, + gs1: $gs1, updatedAt: $updatedAt, ); } diff --git a/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php b/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php index e6ae5f4..31a886b 100644 --- a/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php +++ b/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php @@ -12,12 +12,34 @@ use Shared\Enums\Country; final readonly class CampaignCoupon { + private const int MAX_LOCALES = 2; + + /** + * @param array $availableIn + */ public function __construct( public ProcessingCode $processingCode, public CouponQuantity $quantity, - public Country $availableIn, + public array $availableIn, public ?WarningThresholdQuantity $warningThresholdQuantity = null, public ?PrintRules $printRules = null, ) { + if ($this->availableIn === []) { + throw new \DomainException('Campaign coupon must be available in at least one country.'); + } + + if (count($this->availableIn) > self::MAX_LOCALES) { + throw new \DomainException(sprintf('Campaign coupon cannot be available in more than %d countries.', self::MAX_LOCALES)); + } + + foreach ($this->availableIn as $country) { + if (! $country instanceof Country) { + throw new \DomainException('Campaign coupon availableIn must contain Country instances.'); + } + } + + if (! in_array(Country::FRANCE, $this->availableIn, true)) { + throw new \DomainException('Campaign coupon must always be available in France.'); + } } } diff --git a/src/Domain/Ports/Repositories/CampaignRepository.php b/src/Domain/Ports/Repositories/CampaignRepository.php index a042630..c7ee844 100644 --- a/src/Domain/Ports/Repositories/CampaignRepository.php +++ b/src/Domain/Ports/Repositories/CampaignRepository.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Domain\Ports\Repositories; +use Domain\Models\Entities\Campaign; use Shared\DDD\Ports\Repository; /** @@ -11,4 +12,5 @@ use Shared\DDD\Ports\Repository; */ interface CampaignRepository extends Repository { + public function save(Campaign $campaign): void; } diff --git a/src/Domain/Ports/Repositories/CouponRepository.php b/src/Domain/Ports/Repositories/CouponRepository.php index 458302c..96df75f 100644 --- a/src/Domain/Ports/Repositories/CouponRepository.php +++ b/src/Domain/Ports/Repositories/CouponRepository.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Domain\Ports\Repositories; +use Domain\Models\Entities\Coupon; use Shared\DDD\Ports\Repository; /** @@ -11,4 +12,5 @@ use Shared\DDD\Ports\Repository; */ interface CouponRepository extends Repository { + public function save(Coupon $coupon): void; } diff --git a/tests/Unit/Application/UseCases/Campaign/Transform/TransformCampaignRequestTest.php b/tests/Unit/Application/UseCases/Campaign/Transform/TransformCampaignRequestTest.php new file mode 100644 index 0000000..ed0274a --- /dev/null +++ b/tests/Unit/Application/UseCases/Campaign/Transform/TransformCampaignRequestTest.php @@ -0,0 +1,215 @@ +campaignRequest = CampaignRequest::hydrate( + CampaignRequestId::generate(), + new BrandCode('AAA01'), + new CampaignName('Campaign A'), + new Applicant('John', 'Doe', new Email('john.doe@example.com')), + CampaignRequestType::CLUB, + $requestedCoupon, + CampaignRequestStatus::CREATED, + ); + + $this->input = new Input( + id: $this->campaignRequest->id(), + couponCode: new CouponCode('COU01'), + couponName: $this->campaignRequest->requestedCoupon->name, + amount: $this->campaignRequest->requestedCoupon->moneyAmount, + picture: $this->campaignRequest->requestedCoupon->couponPicture, + diffusion: new CouponDiffusion([$this->campaignRequest->requestedCoupon->diffusion]), + validity: $this->campaignRequest->requestedCoupon->couponValidity, + couponValidityInformation: $this->campaignRequest->requestedCoupon->couponValidityInformation, + couponLegalInformation: [new CouponLegalInformation('Legal text.', Country::FRANCE)], + processingCode: $this->campaignRequest->requestedCoupon->processingCode, + campaignCode: new CampaignCode('CAMP001'), + campaignName: $this->campaignRequest->name, + publication: false, + quantity: new CouponQuantity(100), + availableIn: [Country::FRANCE], + products: $this->campaignRequest->requestedCoupon->products, + warningThresholdQuantity: $this->campaignRequest->requestedCoupon->warningThresholdQuantity, + printRules: $this->campaignRequest->requestedCoupon->printRules, + ); + }); + + afterEach(function (): void { + CarbonImmutable::setTestNow(); + }); + + it('transforms a campaign request into a coupon and a campaign', function (): void { + // GIVEN + CarbonImmutable::setTestNow('2026-06-15 12:00:00'); + $id = $this->campaignRequest->id(); + $brandCode = $this->campaignRequest->brandCode; + + $campaignRequestRepository = \Mockery::mock(CampaignRequestRepository::class); + $campaignRequestRepository->shouldReceive('findById')->once()->with($id)->andReturn($this->campaignRequest); + $campaignRequestRepository->shouldReceive('save')->once()->with(\Mockery::on( + fn(CampaignRequest $saved): bool => $saved->status === CampaignRequestStatus::TRANSFORMED + && $saved->updatedAt !== null, + )); + + $couponRepository = \Mockery::mock(CouponRepository::class); + $couponRepository->shouldReceive('save')->once()->with(\Mockery::on( + fn(Coupon $saved): bool => $saved->code === $this->input->couponCode + && $saved->name === $this->input->couponName + && $saved->amount === $this->input->amount + && $saved->couponLegalInformation === $this->input->couponLegalInformation + && $saved->brandCode === $brandCode, + )); + + $campaignRepository = \Mockery::mock(CampaignRepository::class); + $campaignRepository->shouldReceive('save')->once()->with(\Mockery::on( + fn(Campaign $saved): bool => $saved->code === $this->input->campaignCode + && $saved->name === $this->input->campaignName + && $saved->brandCode === $brandCode + && count($saved->coupons) === 1 + && $saved->coupons[0]->availableIn === $this->input->availableIn, + )); + + $useCase = new TransformCampaignRequest( + $campaignRequestRepository, + $couponRepository, + $campaignRepository, + ); + + // WHEN + $result = $useCase->execute($this->input); + + // THEN + expect($result)->toBeInstanceOf(CampaignRequestTransformed::class) + ->and($result->campaign->code)->toBe($this->input->campaignCode) + ->and($result->campaign->coupons[0]->availableIn)->toBe($this->input->availableIn); + }); + + it('returns CampaignRequestNotFound when the id is not found', function (): void { + // GIVEN + $campaignRequestRepository = \Mockery::mock(CampaignRequestRepository::class); + $campaignRequestRepository->shouldReceive('findById')->once()->with($this->campaignRequest->id())->andReturn(null); + $campaignRequestRepository->shouldNotReceive('save'); + + $couponRepository = \Mockery::mock(CouponRepository::class); + $couponRepository->shouldNotReceive('save'); + + $campaignRepository = \Mockery::mock(CampaignRepository::class); + $campaignRepository->shouldNotReceive('save'); + + $useCase = new TransformCampaignRequest( + $campaignRequestRepository, + $couponRepository, + $campaignRepository, + ); + + // WHEN + $result = $useCase->execute($this->input); + + // THEN + expect($result)->toBeInstanceOf(CampaignRequestNotFound::class); + }); + + it('propagates the domain exception when the campaign request cannot be validated', function (): void { + // GIVEN + $campaignRequest = CampaignRequest::hydrate( + $this->campaignRequest->id(), + $this->campaignRequest->brandCode, + $this->campaignRequest->name, + $this->campaignRequest->applicant, + $this->campaignRequest->campaignType, + $this->campaignRequest->requestedCoupon, + CampaignRequestStatus::TRANSFORMED, + ); + + $campaignRequestRepository = \Mockery::mock(CampaignRequestRepository::class); + $campaignRequestRepository->shouldReceive('findById')->once()->with($this->input->id)->andReturn($campaignRequest); + $campaignRequestRepository->shouldNotReceive('save'); + + $couponRepository = \Mockery::mock(CouponRepository::class); + $couponRepository->shouldNotReceive('save'); + + $campaignRepository = \Mockery::mock(CampaignRepository::class); + $campaignRepository->shouldNotReceive('save'); + + $useCase = new TransformCampaignRequest( + $campaignRequestRepository, + $couponRepository, + $campaignRepository, + ); + + // WHEN + $action = fn(): Output => $useCase->execute($this->input); + + // THEN + expect($action)->toThrow(\DomainException::class, 'Only a created campaign request can be validated.'); + }); +}); diff --git a/tests/Unit/Domain/Models/Entities/CampaignTest.php b/tests/Unit/Domain/Models/Entities/CampaignTest.php index e60cb00..c90b412 100644 --- a/tests/Unit/Domain/Models/Entities/CampaignTest.php +++ b/tests/Unit/Domain/Models/Entities/CampaignTest.php @@ -7,7 +7,6 @@ namespace Tests\Unit\Domain\Models\Entities; use Carbon\CarbonImmutable; use Shared\Enums\Country; use Domain\Models\Entities\Campaign; -use Domain\Models\Entities\Tag; use Domain\Models\ValueObjects\Actor\ActorId; use Domain\Models\ValueObjects\Brand\BrandCode; use Domain\Models\ValueObjects\Campaign\CampaignCode; @@ -39,7 +38,7 @@ describe('campaign', function (): void { new CampaignCoupon( new ProcessingCode('PC1'), new CouponQuantity(100), - Country::FRANCE, + [Country::FRANCE], new WarningThresholdQuantity(100), new PrintRules(maxPerCustomer: 3) ) @@ -109,7 +108,7 @@ describe('campaign', function (): void { new CampaignCoupon( new ProcessingCode('PC1'), new CouponQuantity(100), - Country::FRANCE, + [Country::FRANCE], new WarningThresholdQuantity(100), new PrintRules(maxPerCustomer: 3) ) @@ -146,7 +145,7 @@ describe('campaign', function (): void { new CampaignCoupon( new ProcessingCode('PC1'), new CouponQuantity(100), - Country::FRANCE, + [Country::FRANCE], new WarningThresholdQuantity(100), new PrintRules(maxPerCustomer: 3) ) @@ -188,7 +187,7 @@ describe('campaign', function (): void { new CampaignCoupon( new ProcessingCode('PC1'), new CouponQuantity(100), - Country::FRANCE, + [Country::FRANCE], new WarningThresholdQuantity(100), new PrintRules(maxPerCustomer: 3) ) @@ -233,7 +232,7 @@ describe('campaign', function (): void { new CampaignCoupon( new ProcessingCode('PC1'), new CouponQuantity(100), - Country::FRANCE, + [Country::FRANCE], new WarningThresholdQuantity(100), new PrintRules(maxPerCustomer: 3) ) diff --git a/tests/Unit/Domain/Models/Entities/CouponTest.php b/tests/Unit/Domain/Models/Entities/CouponTest.php index 277f90a..46de29f 100644 --- a/tests/Unit/Domain/Models/Entities/CouponTest.php +++ b/tests/Unit/Domain/Models/Entities/CouponTest.php @@ -61,7 +61,7 @@ describe('coupon', function (): void { $this->createdBy = ActorId::generate(); $this->products = [new IncoCode(35784), new IncoCode(15522)]; $this->availabilityCalendar = new CouponAvailabilityCalendar([new Period(new DateTime('2026-08-25'), new DateTime('2026-10-31'))]); - $this->gtin = new GS1('110101010', BarcodeFormat::EAN13); + $this->gs1 = new GS1('110101010', BarcodeFormat::EAN13); }); afterEach(function (): void { @@ -88,7 +88,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, ); // THEN @@ -106,7 +106,7 @@ describe('coupon', function (): void { ->and($coupon->createdBy)->toBe($this->createdBy) ->and($coupon->products)->toBe($this->products) ->and($coupon->availabilityCalendar)->toBe($this->availabilityCalendar) - ->and($coupon->gtin)->toBe($this->gtin) + ->and($coupon->gs1)->toBe($this->gs1) ->and($coupon->updatedAt)->toBeNull() ->and($coupon->updatedAt())->toBeNull(); }); @@ -136,7 +136,7 @@ describe('coupon', function (): void { // THEN expect($coupon->products)->toBe($this->products) ->and($coupon->availabilityCalendar)->toBe($this->availabilityCalendar) - ->and($coupon->gtin)->toBeNull(); + ->and($coupon->gs1)->toBeNull(); }); it('hydrates a coupon without availability calendar', function (): void { @@ -158,13 +158,13 @@ describe('coupon', function (): void { brandCode: $this->brandCode, createdBy: $this->createdBy, products: $this->products, - gtin: $this->gtin + gs1: $this->gs1 ); // THEN expect($coupon->availabilityCalendar)->toBeNull() ->and($coupon->products)->toBe($this->products) - ->and($coupon->gtin)->toBe($this->gtin); + ->and($coupon->gs1)->toBe($this->gs1); }); it('hydrates a coupon without products', function (): void { @@ -186,13 +186,13 @@ describe('coupon', function (): void { brandCode: $this->brandCode, createdBy: $this->createdBy, availabilityCalendar: $this->availabilityCalendar, - gtin: $this->gtin + gs1: $this->gs1 ); // THEN expect($coupon->products)->toBe([]) ->and($coupon->availabilityCalendar)->toBe($this->availabilityCalendar) - ->and($coupon->gtin)->toBe($this->gtin); + ->and($coupon->gs1)->toBe($this->gs1); }); it('hydrates a coupon with only required fields', function (): void { @@ -219,7 +219,7 @@ describe('coupon', function (): void { expect($coupon->id())->toBe($id) ->and($coupon->products)->toBe([]) ->and($coupon->availabilityCalendar)->toBeNull() - ->and($coupon->gtin)->toBeNull() + ->and($coupon->gs1)->toBeNull() ->and($coupon->updatedAt)->toBeNull() ->and($coupon->updatedAt())->toBeNull(); }); @@ -244,7 +244,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, ); // THEN @@ -272,7 +272,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, ))->toThrow(\DomainException::class, 'Coupon validity information must be CouponValidityInformation instances.'); }); @@ -296,7 +296,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, ))->toThrow(\DomainException::class, 'Coupon legal information must be CouponLegalInformation instances.'); }); @@ -321,7 +321,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, $updatedAt ); @@ -346,7 +346,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, ); // THEN @@ -364,7 +364,7 @@ describe('coupon', function (): void { ->and($coupon->createdBy)->toBe($this->createdBy) ->and($coupon->products)->toBe($this->products) ->and($coupon->availabilityCalendar)->toBe($this->availabilityCalendar) - ->and($coupon->gtin)->toBe($this->gtin) + ->and($coupon->gs1)->toBe($this->gs1) ->and($coupon->updatedAt)->toBeNull() ->and($coupon->updatedAt())->toBeNull(); }); @@ -385,7 +385,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, ); $secondCoupon = Coupon::create( $this->code, @@ -401,7 +401,7 @@ describe('coupon', function (): void { $this->createdBy, $this->products, $this->availabilityCalendar, - $this->gtin, + $this->gs1, ); // THEN diff --git a/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php b/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php index 00697fb..8819473 100644 --- a/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php +++ b/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php @@ -18,7 +18,7 @@ describe('campaign coupon', function (): void { // GIVEN $processingCode = new ProcessingCode('PC1'); $quantity = new CouponQuantity(10); - $availableIn = Country::FRANCE; + $availableIn = [Country::FRANCE]; $warningThresholdQuantity = new WarningThresholdQuantity(100); $printRules = new PrintRules(maxPerCustomer: 3); @@ -37,7 +37,7 @@ describe('campaign coupon', function (): void { // GIVEN $processingCode = new ProcessingCode('PC1'); $quantity = new CouponQuantity(10); - $availableIn = Country::FRANCE; + $availableIn = [Country::FRANCE]; $printRules = new PrintRules(maxPerCustomer: 3); // WHEN @@ -59,7 +59,7 @@ describe('campaign coupon', function (): void { // GIVEN $processingCode = new ProcessingCode('PC1'); $quantity = new CouponQuantity(10); - $availableIn = Country::FRANCE; + $availableIn = [Country::FRANCE]; $warningThresholdQuantity = new WarningThresholdQuantity(100); // WHEN @@ -81,7 +81,7 @@ describe('campaign coupon', function (): void { // GIVEN $processingCode = new ProcessingCode('PC1'); $quantity = new CouponQuantity(10); - $availableIn = Country::FRANCE; + $availableIn = [Country::FRANCE]; // WHEN $campaignCoupon = new CampaignCoupon(processingCode: $processingCode, quantity: $quantity, availableIn: $availableIn);