maxPerCustomer = 3; $this->minMaxPerCustomer = 1; $this->zeroMaxPerCustomer = 0; $this->cooldownDays = 30; $this->minCooldownDays = 1; $this->zeroCooldownDays = 0; }); it('creates print rules with both fields set', function (): void { // GIVEN / WHEN $printRules = new PrintRules( maxPerCustomer: $this->maxPerCustomer, cooldownDays: $this->cooldownDays ); // THEN expect($printRules)->toBeInstanceOf(PrintRules::class) ->and($printRules->maxPerCustomer)->toBe($this->maxPerCustomer) ->and($printRules->cooldownDays)->toBe($this->cooldownDays); }); it('creates print rules with only maxPerCustomer set', function (): void { // GIVEN / WHEN $printRules = new PrintRules( maxPerCustomer: $this->maxPerCustomer ); // THEN expect($printRules->maxPerCustomer)->toBe($this->maxPerCustomer) ->and($printRules->cooldownDays)->toBeNull(); }); it('creates print rules with only cooldownDays set', function (): void { // GIVEN / WHEN $printRules = new PrintRules( cooldownDays: $this->cooldownDays ); // THEN expect($printRules->maxPerCustomer)->toBeNull() ->and($printRules->cooldownDays)->toBe($this->cooldownDays); }); it('rejects print rules without any field set', function (): void { // WHEN / THEN expect(fn (): PrintRules => new PrintRules()) ->toThrow(\InvalidArgumentException::class, 'PrintRules require at least a max per customer or a cooldown days.'); }); it('accepts the minimum value of 1 for both fields', function (): void { // GIVEN / WHEN $printRules = new PrintRules( maxPerCustomer: $this->minMaxPerCustomer, cooldownDays: $this->minCooldownDays ); // THEN expect($printRules->maxPerCustomer)->toBe($this->minMaxPerCustomer) ->and($printRules->cooldownDays)->toBe($this->minCooldownDays); }); it('rejects a maxPerCustomer equal to zero', function (): void { // GIVEN / WHEN / THEN expect(fn (): PrintRules => new PrintRules( maxPerCustomer: $this->zeroMaxPerCustomer ))->toThrow(\InvalidArgumentException::class, 'Max per customer must be greater than 0.'); }); it('rejects a cooldownDays equal to zero', function (): void { // GIVEN / WHEN / THEN expect(fn (): PrintRules => new PrintRules( cooldownDays: $this->zeroCooldownDays ))->toThrow(\InvalidArgumentException::class, 'Cooldown days must be greater than 0.'); }); });