notifications = new InMemoryNotificationRepository; $this->notify = new NotifyAddedPeople($this->notifications, new FakeClock(new DateTimeImmutable('2026-11-25'))); }); it('tells the new assignee and members of a task, but not the one who added them', function () { $this->notify->forTask(new PeopleAddedToTask(7, 'Kuvauspäivä', 3, '2026-0042', 'Messuvideo', 10, [11, 12], 12)); $notifications = array_values($this->notifications->notifications); expect($notifications)->toHaveCount(2) ->and($notifications[0]->userId)->toBe(10) ->and($notifications[0]->type)->toBe(NotificationType::TaskAssigned) ->and($notifications[0]->params)->toBe(['task_id' => 7, 'task_title' => 'Kuvauspäivä', 'job_id' => 3, 'job_number' => '2026-0042', 'job_name' => 'Messuvideo', 'role' => 'assignee']) ->and($notifications[1]->userId)->toBe(11) ->and($notifications[1]->params['role'])->toBe('member'); }); it('tells each person about their new roles on a job, but not the one who gave them', function () { $this->notify->forJob(new PeopleAddedToJob(3, '2026-0042', 'Messuvideo', [10 => ['responsible'], 11 => ['contact', 'member']], 10)); $notifications = array_values($this->notifications->notifications); expect($notifications)->toHaveCount(1) ->and($notifications[0]->userId)->toBe(11) ->and($notifications[0]->type)->toBe(NotificationType::JobAssigned) ->and($notifications[0]->params['roles'])->toBe('contact,member'); }); it('tells again when the same person is added again later', function () { $event = new PeopleAddedToTask(7, 'Kuvauspäivä', 3, '2026-0042', 'Messuvideo', 10, [], 12); $this->notify->forTask($event); $this->notify->forTask($event); expect($this->notifications->notifications)->toHaveCount(2); });