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