feat: build the questionnaire form from its definition

This commit is contained in:
fromme committed 2026-10-27 16:47:38 +01:00
1 parent d06b647dac
commit 8070fda64d
4 files changed
+435

No files matched your search

@@ -44,6 +44,22 @@ class DefinitionTest extends TestCase
$this->assertFalse($definition->isVisible($details, ['damage' => 'no', 'claim' => 'expected']));
}
public function testWithoutHiddenAnswersDropsHiddenEmptyAndUnknownAnswers(): void
{
$answers = [
'damage' => 'no',
'claim' => 'expected', // hidden now that damage is "no"
'details' => 'Spiegel ab', // hidden in turn
'unknown' => 'x', // not a question of this definition
];
$this->assertSame(['damage' => 'no'], $this->definition()->withoutHiddenAnswers($answers));
$this->assertSame(
['damage' => 'yes', 'claim' => 'settled'],
$this->definition()->withoutHiddenAnswers(['damage' => 'yes', 'claim' => 'settled', 'details' => '']),
);
}
private function definition(): Definition
{
$yesNo = [new Option('yes', 'Ja'), new Option('no', 'Nein')];