diff --git a/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php b/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php index e6ae5f4..ba56632 100644 --- a/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php +++ b/src/Domain/Models/ValueObjects/Campaign/CampaignCoupon.php @@ -7,7 +7,6 @@ namespace Domain\Models\ValueObjects\Campaign; 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; final readonly class CampaignCoupon @@ -16,7 +15,6 @@ final readonly class CampaignCoupon public ProcessingCode $processingCode, public CouponQuantity $quantity, public Country $availableIn, - public ?WarningThresholdQuantity $warningThresholdQuantity = null, public ?PrintRules $printRules = null, ) { } diff --git a/src/Domain/Models/ValueObjects/RequestedCoupon/RequestedCoupon.php b/src/Domain/Models/ValueObjects/RequestedCoupon/RequestedCoupon.php index 1e2b565..8fc0c3c 100644 --- a/src/Domain/Models/ValueObjects/RequestedCoupon/RequestedCoupon.php +++ b/src/Domain/Models/ValueObjects/RequestedCoupon/RequestedCoupon.php @@ -13,17 +13,13 @@ use Domain\Models\ValueObjects\MoneyAmount; use Domain\Models\ValueObjects\Period; use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Shared\Enums\Country; final readonly class RequestedCoupon { - private const int DEFAULT_WARNING_THRESHOLD_QUANTITY = 100; private const int MIN_FACE_VALUE_IN_CENTS = 1; private const int MAX_FACE_VALUE_IN_CENTS = 300; - public WarningThresholdQuantity $warningThresholdQuantity; - /** * @param array $couponValidityInformation * @param array $products @@ -39,7 +35,6 @@ final readonly class RequestedCoupon public array $products = [], public ?PrintRules $printRules = null, public ?GS1 $gs1 = null, - ?WarningThresholdQuantity $warningThresholdQuantity = null, ) { $money = $this->moneyAmount->value; @@ -63,8 +58,6 @@ final readonly class RequestedCoupon if ($this->gs1 instanceof GS1 && !$this->hasValidityInformationFor(Country::BENELUX)) { throw new \DomainException('A GS1 coupon requires validity information for Benelux.'); } - - $this->warningThresholdQuantity = $warningThresholdQuantity ?? new WarningThresholdQuantity(self::DEFAULT_WARNING_THRESHOLD_QUANTITY); } private function hasValidityInformationFor(Country $country): bool diff --git a/src/Domain/Models/ValueObjects/WarningThresholdQuantity.php b/src/Domain/Models/ValueObjects/WarningThresholdQuantity.php deleted file mode 100644 index 682608e..0000000 --- a/src/Domain/Models/ValueObjects/WarningThresholdQuantity.php +++ /dev/null @@ -1,16 +0,0 @@ -value < 0) { - throw new \DomainException('Warning threshold quantity cannot be negative.'); - } - } -} diff --git a/tests/Unit/Application/UseCases/CampaignRequest/Create/CreateCampaignRequestTest.php b/tests/Unit/Application/UseCases/CampaignRequest/Create/CreateCampaignRequestTest.php index e7d52ea..efd146e 100644 --- a/tests/Unit/Application/UseCases/CampaignRequest/Create/CreateCampaignRequestTest.php +++ b/tests/Unit/Application/UseCases/CampaignRequest/Create/CreateCampaignRequestTest.php @@ -25,7 +25,6 @@ use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Domain\Ports\Repositories\BrandRepository; use Domain\Ports\Repositories\CampaignRequestRepository; use Shared\Enums\Country; @@ -52,8 +51,7 @@ beforeEach(function (): void { new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE), ], products: [new IncoCode(35784), new IncoCode(15522)], - printRules: new PrintRules(maxPerCustomer: 3), - warningThresholdQuantity: new WarningThresholdQuantity(10), + printRules: new PrintRules(maxPerCustomer: 3) ), ); }); diff --git a/tests/Unit/Application/UseCases/CampaignRequest/Find/FindCampaignRequestTest.php b/tests/Unit/Application/UseCases/CampaignRequest/Find/FindCampaignRequestTest.php index 2173f21..912dc8d 100644 --- a/tests/Unit/Application/UseCases/CampaignRequest/Find/FindCampaignRequestTest.php +++ b/tests/Unit/Application/UseCases/CampaignRequest/Find/FindCampaignRequestTest.php @@ -35,7 +35,6 @@ use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Domain\Ports\Repositories\BrandRepository; use Domain\Ports\Repositories\CampaignRequestRepository; use Shared\DDD\UseCases\Input as BaseInput; @@ -62,8 +61,7 @@ describe('find campaign request use case', function (): void { ], [new IncoCode(35784), new IncoCode(15522)], new PrintRules(maxPerCustomer: 3), - new GS1('01234567890128', BarcodeFormat::EAN13), - new WarningThresholdQuantity(10) + new GS1('01234567890128', BarcodeFormat::EAN13) ); }); diff --git a/tests/Unit/Application/UseCases/CampaignRequest/List/ListCampaignsRequestTest.php b/tests/Unit/Application/UseCases/CampaignRequest/List/ListCampaignsRequestTest.php index 7699b81..aa717b2 100644 --- a/tests/Unit/Application/UseCases/CampaignRequest/List/ListCampaignsRequestTest.php +++ b/tests/Unit/Application/UseCases/CampaignRequest/List/ListCampaignsRequestTest.php @@ -28,7 +28,6 @@ use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Domain\Ports\Repositories\CampaignRequestRepository; use Shared\Enums\Country; use Shared\Enums\Currency; @@ -54,8 +53,7 @@ describe('list campaigns request use case', function (): void { ], [new IncoCode(35784), new IncoCode(15522)], new PrintRules(maxPerCustomer: 3), - new GS1('01234567890128', BarcodeFormat::EAN13), - new WarningThresholdQuantity(10) + new GS1('01234567890128', BarcodeFormat::EAN13) ); $this->couponB = new RequestedCoupon( @@ -71,8 +69,7 @@ describe('list campaigns request use case', function (): void { ], [new IncoCode(24514), new IncoCode(46259)], new PrintRules(maxPerCustomer: 3), - new GS1('01234567890128', BarcodeFormat::EAN13), - new WarningThresholdQuantity(10) + new GS1('01234567890128', BarcodeFormat::EAN13) ); }); diff --git a/tests/Unit/Application/UseCases/CampaignRequest/Reject/RejectCampaignRequestTest.php b/tests/Unit/Application/UseCases/CampaignRequest/Reject/RejectCampaignRequestTest.php index d0cf988..5cc0ccc 100644 --- a/tests/Unit/Application/UseCases/CampaignRequest/Reject/RejectCampaignRequestTest.php +++ b/tests/Unit/Application/UseCases/CampaignRequest/Reject/RejectCampaignRequestTest.php @@ -31,7 +31,6 @@ use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Domain\Ports\Repositories\CampaignRequestRepository; use Shared\Enums\Country; use Shared\Enums\Currency; @@ -55,8 +54,7 @@ describe('reject campaign request use case', function (): void { ], [new IncoCode(35784), new IncoCode(15522)], new PrintRules(maxPerCustomer: 3), - new GS1('01234567890128', BarcodeFormat::EAN13), - new WarningThresholdQuantity(10) + new GS1('01234567890128', BarcodeFormat::EAN13) ); }); diff --git a/tests/Unit/Domain/Models/Entities/CampaignRequestTest.php b/tests/Unit/Domain/Models/Entities/CampaignRequestTest.php index 1e18321..e1b936f 100644 --- a/tests/Unit/Domain/Models/Entities/CampaignRequestTest.php +++ b/tests/Unit/Domain/Models/Entities/CampaignRequestTest.php @@ -26,7 +26,6 @@ use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Ramsey\Uuid\Uuid; use Shared\Enums\Country; use Shared\Enums\Currency; @@ -50,8 +49,7 @@ describe('campaign request', function (): void { ], [new IncoCode(35784), new IncoCode(15522)], new PrintRules(maxPerCustomer: 3), - new GS1('01234567890128', BarcodeFormat::EAN13), - new WarningThresholdQuantity(10) + new GS1('01234567890128', BarcodeFormat::EAN13) ); $this->code = new BrandCode('AAA01'); $this->name = new CampaignName('Campaign A'); diff --git a/tests/Unit/Domain/Models/Entities/CampaignTest.php b/tests/Unit/Domain/Models/Entities/CampaignTest.php index 0718b78..403200c 100644 --- a/tests/Unit/Domain/Models/Entities/CampaignTest.php +++ b/tests/Unit/Domain/Models/Entities/CampaignTest.php @@ -16,7 +16,6 @@ use Domain\Models\ValueObjects\Campaign\CampaignName; use Domain\Models\ValueObjects\Coupon\CouponQuantity; use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Ramsey\Uuid\Uuid; covers(Campaign::class); @@ -32,7 +31,6 @@ describe('campaign', function (): void { new ProcessingCode('PC1'), new CouponQuantity(100), Country::FRANCE, - new WarningThresholdQuantity(100), new PrintRules(maxPerCustomer: 3) ) ]; diff --git a/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php b/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php index be7fc49..9938215 100644 --- a/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php +++ b/tests/Unit/Domain/Models/ValueObjects/Campaign/CampaignCouponTest.php @@ -8,7 +8,6 @@ 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); @@ -18,7 +17,6 @@ describe('campaign coupon', function (): void { $this->processingCode = new ProcessingCode('PC1'); $this->quantity = new CouponQuantity(10); $this->availableIn = Country::FRANCE; - $this->warningThresholdQuantity = new WarningThresholdQuantity(100); $this->printRules = new PrintRules(maxPerCustomer: 3); }); @@ -28,7 +26,6 @@ describe('campaign coupon', function (): void { $this->processingCode, $this->quantity, $this->availableIn, - $this->warningThresholdQuantity, $this->printRules ); @@ -36,7 +33,6 @@ describe('campaign coupon', function (): void { expect($campaignCoupon->processingCode)->toBe($this->processingCode) ->and($campaignCoupon->quantity)->toBe($this->quantity) ->and($campaignCoupon->availableIn)->toBe($this->availableIn) - ->and($campaignCoupon->warningThresholdQuantity)->toBe($this->warningThresholdQuantity) ->and($campaignCoupon->printRules)->toBe($this->printRules); }); @@ -62,14 +58,12 @@ describe('campaign coupon', function (): void { processingCode: $this->processingCode, quantity: $this->quantity, availableIn: $this->availableIn, - warningThresholdQuantity: $this->warningThresholdQuantity ); // THEN expect($campaignCoupon->processingCode)->toBe($this->processingCode) ->and($campaignCoupon->quantity)->toBe($this->quantity) - ->and($campaignCoupon->availableIn)->toBe($this->availableIn) - ->and($campaignCoupon->warningThresholdQuantity)->toBe($this->warningThresholdQuantity); + ->and($campaignCoupon->availableIn)->toBe($this->availableIn); }); it('creates a valid campaign coupon whitout warning threshold quantity and print rules', function (): void { diff --git a/tests/Unit/Domain/Models/ValueObjects/RequestedCoupon/RequestedCouponTest.php b/tests/Unit/Domain/Models/ValueObjects/RequestedCoupon/RequestedCouponTest.php index e3d3efc..111a145 100644 --- a/tests/Unit/Domain/Models/ValueObjects/RequestedCoupon/RequestedCouponTest.php +++ b/tests/Unit/Domain/Models/ValueObjects/RequestedCoupon/RequestedCouponTest.php @@ -18,7 +18,6 @@ use Domain\Models\ValueObjects\PrintRules; use Domain\Models\ValueObjects\ProcessingCode; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon; use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity; -use Domain\Models\ValueObjects\WarningThresholdQuantity; use Shared\Enums\Country; use Shared\Enums\Currency; use Shared\ValueObjects\Money; @@ -48,7 +47,6 @@ describe('requested coupon', function (): void { $this->products = [new IncoCode(35784), new IncoCode(15522)]; $this->printRules = new PrintRules(maxPerCustomer: 3); $this->gs1 = new GS1('01234567890128', BarcodeFormat::EAN13); - $this->warningThresholdQuantity = new WarningThresholdQuantity(10); }); afterEach(function (): void { @@ -68,7 +66,6 @@ describe('requested coupon', function (): void { $this->products, $this->printRules, $this->gs1, - $this->warningThresholdQuantity ); // THEN @@ -81,8 +78,7 @@ describe('requested coupon', function (): void { ->and($coupon->couponValidityInformation)->toBe($this->couponValidityInformation) ->and($coupon->products)->toBe($this->products) ->and($coupon->printRules)->toBe($this->printRules) - ->and($coupon->gs1)->toBe($this->gs1) - ->and($coupon->warningThresholdQuantity)->toBe($this->warningThresholdQuantity); + ->and($coupon->gs1)->toBe($this->gs1); }); it('hydrates a requested coupon without products', function (): void { @@ -96,15 +92,13 @@ describe('requested coupon', function (): void { couponValidity: $this->couponValidity, couponValidityInformation: $this->couponValidityInformation, printRules: $this->printRules, - gs1: $this->gs1, - warningThresholdQuantity: $this->warningThresholdQuantity + gs1: $this->gs1 ); // THEN expect($coupon->products)->toBe([]) ->and($coupon->printRules)->toBe($this->printRules) - ->and($coupon->gs1)->toBe($this->gs1) - ->and($coupon->warningThresholdQuantity)->toBe($this->warningThresholdQuantity); + ->and($coupon->gs1)->toBe($this->gs1); }); it('hydrates a requested coupon without print rules', function (): void { @@ -118,15 +112,13 @@ describe('requested coupon', function (): void { couponValidity: $this->couponValidity, couponValidityInformation: $this->couponValidityInformation, products: $this->products, - gs1: $this->gs1, - warningThresholdQuantity: $this->warningThresholdQuantity + gs1: $this->gs1 ); // THEN expect($coupon->printRules)->toBeNull() ->and($coupon->products)->toBe($this->products) - ->and($coupon->gs1)->toBe($this->gs1) - ->and($coupon->warningThresholdQuantity)->toBe($this->warningThresholdQuantity); + ->and($coupon->gs1)->toBe($this->gs1); }); it('hydrates a requested coupon without gs1', function (): void { @@ -140,37 +132,13 @@ describe('requested coupon', function (): void { couponValidity: $this->couponValidity, couponValidityInformation: $this->couponValidityInformation, products: $this->products, - printRules: $this->printRules, - warningThresholdQuantity: $this->warningThresholdQuantity + printRules: $this->printRules ); // THEN expect($coupon->gs1)->toBeNull() ->and($coupon->products)->toBe($this->products) - ->and($coupon->printRules)->toBe($this->printRules) - ->and($coupon->warningThresholdQuantity)->toBe($this->warningThresholdQuantity); - }); - - it('defaults the warning threshold quantity to 100 when not provided', function (): void { - // GIVEN / WHEN - $coupon = new RequestedCoupon( - name: $this->name, - quantity: $this->quantity, - diffusion: $this->diffusion, - moneyAmount: $this->moneyAmount, - processingCode: $this->processingCode, - couponValidity: $this->couponValidity, - couponValidityInformation: $this->couponValidityInformation, - products: $this->products, - printRules: $this->printRules, - gs1: $this->gs1, - ); - - // THEN - expect($coupon->warningThresholdQuantity)->toEqual(new WarningThresholdQuantity(100)) - ->and($coupon->products)->toBe($this->products) - ->and($coupon->printRules)->toBe($this->printRules) - ->and($coupon->gs1)->toBe($this->gs1); + ->and($coupon->printRules)->toBe($this->printRules); }); it('hydrates a requested coupon with only required fields', function (): void { @@ -188,8 +156,7 @@ describe('requested coupon', function (): void { // THEN expect($coupon->products)->toBe([]) ->and($coupon->printRules)->toBeNull() - ->and($coupon->gs1)->toBeNull() - ->and($coupon->warningThresholdQuantity)->toEqual(new WarningThresholdQuantity(100)); + ->and($coupon->gs1)->toBeNull(); }); it('throws when there is no validity information for france', function (): void { @@ -217,8 +184,7 @@ describe('requested coupon', function (): void { ['Not a CouponValidityInformation'], $this->products, $this->printRules, - $this->gs1, - $this->warningThresholdQuantity + $this->gs1 ))->toThrow(\DomainException::class, 'Coupon validity information must be CouponValidityInformation instances.'); }); diff --git a/tests/Unit/Domain/Models/ValueObjects/WarningThresholdQuantityTest.php b/tests/Unit/Domain/Models/ValueObjects/WarningThresholdQuantityTest.php deleted file mode 100644 index de80f52..0000000 --- a/tests/Unit/Domain/Models/ValueObjects/WarningThresholdQuantityTest.php +++ /dev/null @@ -1,48 +0,0 @@ -value = 10; - $this->zeroValue = 0; - $this->negativeValue = -1; - }); - - it('creates a valid warning threshold quantity', function (): void { - // GIVEN / WHEN - $warningThresholdQuantity = new WarningThresholdQuantity( - $this->value - ); - - // THEN - expect($warningThresholdQuantity)->toBeInstanceOf(WarningThresholdQuantity::class) - ->and($warningThresholdQuantity->value)->toBe($this->value); - }); - - it('accepts a zero value, meaning no warning', function (): void { - // GIVEN / WHEN - $warningThresholdQuantity = new WarningThresholdQuantity( - $this->zeroValue - ); - - // THEN - expect($warningThresholdQuantity->value)->toBe($this->zeroValue); - }); - - it('rejects a negative value', function (): void { - // GIVEN / WHEN - $action = fn (): WarningThresholdQuantity => new WarningThresholdQuantity( - $this->negativeValue - ); - - // THEN - expect($action)->toThrow(\DomainException::class, 'Warning threshold quantity cannot be negative.'); - }); -});