feat: answer received form submissions by mail
This commit is contained in:
1 parent
19364df2db
commit
aa728ddc99
22 files changed
+974
-9
No files matched your search
@@ -322,6 +322,107 @@ class ApplicationFormControllerTest extends WebTestCase
|
||||
$this->assertSame(2, $this->countSubmissions());
|
||||
}
|
||||
|
||||
/**
|
||||
* The receipt mail only goes out for an applicant the form reported as EU (incl. Switzerland).
|
||||
* Everything else - "no", and a form that never asks - is silence, so an unmapped field can
|
||||
* never mail someone by accident.
|
||||
*/
|
||||
public function testTheReceiptGoesOutForAnEuApplicant(): void
|
||||
{
|
||||
$this->post($this->eligiblePayload());
|
||||
|
||||
$this->assertSame(Response::HTTP_ACCEPTED, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertEmailCount(1);
|
||||
$this->assertNotNull($this->lastSubmission()->getFirstMailSentAt());
|
||||
$this->assertTrue($this->lastSubmission()->isEu());
|
||||
}
|
||||
|
||||
public function testNoReceiptForANonEuApplicant(): void
|
||||
{
|
||||
$this->post(['eu' => false] + $this->eligiblePayload());
|
||||
|
||||
$this->assertSame(Response::HTTP_ACCEPTED, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertEmailCount(0);
|
||||
$this->assertNull($this->lastSubmission()->getFirstMailSentAt());
|
||||
$this->assertFalse($this->lastSubmission()->isEu());
|
||||
}
|
||||
|
||||
public function testNoReceiptWhenTheFormDoesNotAsk(): void
|
||||
{
|
||||
$payload = $this->eligiblePayload();
|
||||
unset($payload['eu']);
|
||||
|
||||
$this->post($payload);
|
||||
|
||||
$this->assertSame(Response::HTTP_ACCEPTED, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertEmailCount(0);
|
||||
$this->assertNull($this->lastSubmission()->isEu());
|
||||
$this->assertNull($this->lastSubmission()->getFirstMailSentAt());
|
||||
}
|
||||
|
||||
/**
|
||||
* A form posts "1" as readily as a JSON true, and dropping an application over the spelling
|
||||
* would be absurd - the same tolerance pageUid has.
|
||||
*/
|
||||
public function testAQuotedEuFlagStillEarnsTheReceipt(): void
|
||||
{
|
||||
$this->post(['eu' => '1'] + $this->eligiblePayload());
|
||||
|
||||
$this->assertEmailCount(1);
|
||||
$this->assertTrue($this->lastSubmission()->isEu());
|
||||
}
|
||||
|
||||
public function testAnEmptyEuFlagIsNotAYes(): void
|
||||
{
|
||||
$this->post(['eu' => ''] + $this->eligiblePayload());
|
||||
|
||||
$this->assertEmailCount(0);
|
||||
$this->assertFalse($this->lastSubmission()->isEu());
|
||||
}
|
||||
|
||||
/**
|
||||
* Not a silent null: a mapping that quietly stopped every receipt mail is worse than a 400
|
||||
* the TYPO3 side logs.
|
||||
*/
|
||||
public function testAnUnparseableEuFlagIsRejected(): void
|
||||
{
|
||||
$this->post(['eu' => 'vielleicht'] + $this->eligiblePayload());
|
||||
|
||||
$this->assertSame(Response::HTTP_BAD_REQUEST, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertSame(0, $this->countSubmissions());
|
||||
$this->assertEmailCount(0);
|
||||
}
|
||||
|
||||
public function testAnEligibleSubmissionWithoutAnEmailAddressIsStillStored(): void
|
||||
{
|
||||
$payload = $this->eligiblePayload();
|
||||
unset($payload['email']);
|
||||
|
||||
$this->post($payload);
|
||||
|
||||
$this->assertSame(Response::HTTP_ACCEPTED, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertEmailCount(0);
|
||||
$this->assertSame(1, $this->countSubmissions());
|
||||
$this->assertNull($this->lastSubmission()->getFirstMailSentAt());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function eligiblePayload(): array
|
||||
{
|
||||
return [
|
||||
'form' => 'applicationform',
|
||||
'formLabel' => 'Bewerbungsformular',
|
||||
'submittedAt' => '2026-09-22T12:30:00+02:00',
|
||||
'firstName' => 'Anna',
|
||||
'lastName' => 'Muster',
|
||||
'email' => '[email protected]',
|
||||
'eu' => true,
|
||||
'details' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user