fix: accept the German W as a gender on the application endpoint

This commit is contained in:
fromme committed 2026-09-26 10:25:48 +02:00
1 parent 5141673bcd
commit e460b18661
3 files changed
+107 -5

No files matched your search

@@ -359,6 +359,50 @@ class ApplicationFormControllerTest extends WebTestCase
}
}
/**
* The German spelling of female. The forms are German and some of them post W; it is accepted
* and stored as F, so the row, the provisioned teamer and the payload all read the same
* whichever spelling arrived.
*/
public function testTheGermanWIsAcceptedAndStoredAsF(): void
{
$this->post(['gender' => 'W'] + $this->payload());
$this->assertSame(Response::HTTP_ACCEPTED, $this->client->getResponse()->getStatusCode());
$submission = $this->lastSubmission();
$this->assertSame('F', $submission->getGender());
$this->assertSame('W', $submission->toPayload()['geschlecht']);
$this->assertSame('W', $submission->getPayload()['gender'] ?? null);
}
/**
* Case is the sender's business, not a reason to lose an application: every spelling a form
* can post lands on the same stored value.
*
* @dataProvider genderSpellings
*/
public function testAGenderIsReadWhateverItsCase(string $posted, string $stored): void
{
$this->post(['gender' => $posted] + $this->payload());
$this->assertSame(Response::HTTP_ACCEPTED, $this->client->getResponse()->getStatusCode());
$this->assertSame($stored, $this->lastSubmission()->getGender());
}
/**
* @return iterable<string, array{string, string}>
*/
public static function genderSpellings(): iterable
{
yield 'lowercase f' => ['f', 'F'];
yield 'lowercase w' => ['w', 'F'];
yield 'lowercase m' => ['m', 'M'];
yield 'lowercase d' => ['d', 'D'];
yield 'padded' => [' W ', 'F'];
}
/**
* The mapped vocabulary grows on the website side without a release here. An unknown key is
* ignored, and kept in the raw payload so it can be mapped later without losing the answers