Skip to content

Commit 6aa5f3b

Browse files
committed
test(policy): validate empty allowed values business rule
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 80ab722 commit 6aa5f3b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/php/Unit/Service/Policy/Model/PolicySpecTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,30 @@ public function testValidationUsesProvidedContext(): void {
7575
$this->expectException(\InvalidArgumentException::class);
7676
$spec->validateValue('parallel', new PolicyContext());
7777
}
78+
79+
public function testValidationAllowsAnyValueWhenAllowedValuesIsEmpty(): void {
80+
$spec = new PolicySpec(
81+
key: 'signature_text_template',
82+
defaultSystemValue: '',
83+
allowedValues: [],
84+
);
85+
86+
$spec->validateValue('any free text', new PolicyContext());
87+
$spec->validateValue(12.5, new PolicyContext());
88+
89+
$this->addToAssertionCount(1);
90+
}
91+
92+
public function testValidationStillRejectsValueWhenAllowedValuesIsDefined(): void {
93+
$spec = new PolicySpec(
94+
key: 'signature_render_mode',
95+
defaultSystemValue: 'default',
96+
allowedValues: ['default', 'graphic', 'text'],
97+
);
98+
99+
$spec->validateValue('graphic', new PolicyContext());
100+
101+
$this->expectException(\InvalidArgumentException::class);
102+
$spec->validateValue('unsupported_mode', new PolicyContext());
103+
}
78104
}

0 commit comments

Comments
 (0)