feat: remind of open questionnaires nightly for a week, then weekly

This commit is contained in:
fromme committed 2026-11-10 17:13:05 +01:00
1 parent e72616fdbf
commit 8b5b7584b1
4 files changed
+60 -11

No files matched your search

@@ -73,11 +73,44 @@ class QuestionnaireReminderServiceTest extends TestCase
$this->assertSame('Sent 2 questionnaire reminders to teamers', $this->service->sendReminders(new \DateTimeImmutable('2026-11-20')));
$this->assertSame(['[email protected]', '[email protected]'], array_keys($sent));
// labelled as everywhere in the reminders, by Destination::__toString()
// the placement on its 13th night is not due by itself, but comes along with the one that
// is; labelled as everywhere in the reminders, by Destination::__toString()
$this->assertSame('07.11.26 - 14.11.26 Skireise, 31.10.26 - 07.11.26 Skireise', $sent['[email protected]']);
$this->assertSame('07.11.26 - 14.11.26 Skireise', $sent['[email protected]']);
}
/**
* Nightly for a week, then weekly: a teamer who never submits is not mailed every night for
* the rest of the season.
*/
public function testItRemindsNightlyForAWeekThenWeekly(): void
{
$this->repository->method('findQuestionnaireReminders')->willReturn([$this->placement($this->teamer('[email protected]'), '2026-11-14')]);
$nights = [];
for ($night = 1; $night <= 30; ++$night) {
$today = new \DateTimeImmutable('2026-11-14')->modify(sprintf('+%d days', $night));
if ('Sent 1 questionnaire reminders to teamers' === $this->service->sendReminders($today)) {
$nights[] = $night;
}
}
$this->assertSame([1, 2, 3, 4, 5, 6, 7, 14, 21, 28], $nights);
}
/**
* On its 13th night a placement waits for the weekly 14th.
*/
public function testAPlacementBetweenItsWeeklyNightsAloneSendsNothing(): void
{
$kim = $this->teamer('[email protected]');
$this->repository->method('findQuestionnaireReminders')->willReturn([$this->placement($kim, '2026-11-07')]);
$this->assertSame('Sent 0 questionnaire reminders to teamers', $this->service->sendReminders(new \DateTimeImmutable('2026-11-20')));
}
public function testATeamerWithoutAnAddressIsSkipped(): void
{
$this->repository->method('findQuestionnaireReminders')->willReturn([$this->placement(new Teamer(), '2026-11-14')]);