feat: send season deadline summary to the office address

This commit is contained in:
fromme committed 2026-09-26 12:13:16 +02:00
1 parent cf876ed224
commit 77986776c2
2 files changed
+31 -42

No files matched your search

@@ -13,9 +13,7 @@ use App\Entity\Embeddable\Communication;
use App\Entity\SeasonAssignment;
use App\Entity\SeasonAssignmentTask;
use App\Entity\Teamer;
use App\Entity\User;
use App\Repository\SeasonAssignmentTaskRepository;
use App\Repository\UserRepository;
use App\Service\Cron\SeasonTaskReminderService;
use App\Service\Season\SeasonAssignmentLabeler;
use App\Service\Season\SeasonTaskDeadlineResolver;
@@ -31,14 +29,12 @@ use Psr\Log\NullLogger;
class SeasonTaskReminderServiceTest extends TestCase
{
private SeasonAssignmentTaskRepository&MockObject $repository;
private UserRepository&MockObject $userRepository;
private Mailer&MockObject $mailer;
private SeasonTaskReminderService $service;
protected function setUp(): void
{
$this->repository = $this->createMock(SeasonAssignmentTaskRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->mailer = $this->createMock(Mailer::class);
$this->service = new SeasonTaskReminderService(
@@ -49,7 +45,6 @@ class SeasonTaskReminderServiceTest extends TestCase
new HouseCatalog(['AGR' => 'Rotbach'])
),
new SeasonCalendar('11-01', '04-01'),
$this->userRepository,
$this->mailer,
new NullLogger(),
);
@@ -58,7 +53,6 @@ class SeasonTaskReminderServiceTest extends TestCase
public function testTheSummaryFiresOnTheDeadlineDay(): void
{
$this->repository->method('findOpen')->willReturn([$this->task('2026-11-01')]);
$this->userRepository->method('getUsersByRoles')->willReturn([$this->admin()]);
$this->mailer
->expects($this->once())
@@ -76,6 +70,28 @@ class SeasonTaskReminderServiceTest extends TestCase
$this->service->sendDeadlineSummary(new \DateTimeImmutable('2026-10-01'));
}
/**
* The summary is one office mail, not a copy per admin: it passes no recipient at all and so
* lands on the Mailer default, APP_DEFAULT_EMAIL_TO.
*/
public function testTheSummaryGoesOutOnceToTheDefaultAddress(): void
{
$this->repository->method('findOpen')->willReturn([$this->task('2026-11-01')]);
$this->mailer
->expects($this->once())
->method('createAndSendEmail')
->with(
$this->anything(),
$this->callback(
static fn (array $options): bool => false === array_key_exists('to', $options)
)
)
;
$this->service->sendDeadlineSummary(new \DateTimeImmutable('2026-10-01'));
}
public function testTheSummaryDoesNotFireTheDayAfter(): void
{
$this->repository->method('findOpen')->willReturn([$this->task('2026-11-01')]);
@@ -92,7 +108,6 @@ class SeasonTaskReminderServiceTest extends TestCase
public function testCoincidingDeadlinesAreReportedOnceAsTheFirst(): void
{
$this->repository->method('findOpen')->willReturn([$this->task('2026-11-01')]);
$this->userRepository->method('getUsersByRoles')->willReturn([$this->admin()]);
$levels = [];
@@ -115,7 +130,6 @@ class SeasonTaskReminderServiceTest extends TestCase
$task = $this->task('2026-11-01')->setDeadlineOverride2(new \DateTimeImmutable('2026-10-15'));
$this->repository->method('findOpen')->willReturn([$task]);
$this->userRepository->method('getUsersByRoles')->willReturn([$this->admin()]);
$levels = [];
@@ -133,18 +147,6 @@ class SeasonTaskReminderServiceTest extends TestCase
$this->assertSame([2], $levels);
}
public function testAnAdminMutingNotificationsIsSkipped(): void
{
$this->repository->method('findOpen')->willReturn([$this->task('2026-11-01')]);
$this->userRepository->method('getUsersByRoles')->willReturn([
$this->admin()->setMuteNotifications(true),
]);
$this->mailer->expects($this->never())->method('createAndSendEmail');
$this->service->sendDeadlineSummary(new \DateTimeImmutable('2026-10-01'));
}
public function testTheDigestOnlyGoesOutOnMondays(): void
{
$this->repository->expects($this->never())->method('findOpen');
@@ -221,9 +223,4 @@ class SeasonTaskReminderServiceTest extends TestCase
return $task;
}
private function admin(): User
{
return (new User())->setEmail('[email protected]');
}
}