toBeInstanceOf(PrintRules::class) ->and($printRules->maxPerCustomer)->toBe($maxPerCustomer) ->and($printRules->cooldownDays)->toBe($cooldownDays); }); it('creates print rules with only maxPerCustomer set', function () use ($maxPerCustomer): void { // GIVEN / WHEN $printRules = new PrintRules( maxPerCustomer: $maxPerCustomer ); // THEN expect($printRules->maxPerCustomer)->toBe($maxPerCustomer) ->and($printRules->cooldownDays)->toBeNull(); }); it('creates print rules with only cooldownDays set', function () use ($cooldownDays): void { // GIVEN / WHEN $printRules = new PrintRules( cooldownDays: $cooldownDays ); // THEN expect($printRules->maxPerCustomer)->toBeNull() ->and($printRules->cooldownDays)->toBe($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 () use ($minMaxPerCustomer, $minCooldownDays): void { // GIVEN / WHEN $printRules = new PrintRules( maxPerCustomer: $minMaxPerCustomer, cooldownDays: $minCooldownDays ); // THEN expect($printRules->maxPerCustomer)->toBe($minMaxPerCustomer) ->and($printRules->cooldownDays)->toBe($minCooldownDays); }); it('rejects a maxPerCustomer equal to zero', function () use ($zeroMaxPerCustomer): void { // GIVEN / WHEN / THEN expect(fn (): PrintRules => new PrintRules( maxPerCustomer: $zeroMaxPerCustomer ))->toThrow(\InvalidArgumentException::class, 'Max per customer must be greater than 0.'); }); it('rejects a cooldownDays equal to zero', function () use ($zeroCooldownDays): void { // GIVEN / WHEN / THEN expect(fn (): PrintRules => new PrintRules( cooldownDays: $zeroCooldownDays ))->toThrow(\InvalidArgumentException::class, 'Cooldown days must be greater than 0.'); }); });