$assignments */ function calendarTask(int $id, string $from, string $to, array $assignments, ?string $dueOn = null): CalendarTask { return new CalendarTask($id, 1, '2026-001', 'Kampanja', 'Tehtävä '.$id, TaskStatus::Waiting, $dueOn, null, $from, $to, $assignments); } it('puts each task on its assignees rows and overlapping tasks on their own lanes', function () { $days = ['2026-12-07', '2026-12-08', '2026-12-09', '2026-12-10']; $tasks = [ calendarTask(1, '2026-12-07', '2026-12-08', [new CalendarAssignment(10, '2026-12-07', '2026-12-08', 480), new CalendarAssignment(11, '2026-12-07', '2026-12-09', 480)]), calendarTask(2, '2026-12-08', '2026-12-08', [new CalendarAssignment(10, '2026-12-08', '2026-12-08', 120)]), calendarTask(3, '2026-12-09', '2026-12-20', [new CalendarAssignment(10, null, null, 0)], dueOn: '2026-12-15'), calendarTask(4, '2026-12-01', '2026-12-07', []), ]; $people = [['id' => 10, 'name' => 'Eero'], ['id' => 11, 'name' => 'Aino'], ['id' => null, 'name' => 'Ei tekijää']]; $rows = TaskCalendarLayout::build($days, $people, $tasks, [10 => ['2026-12-08' => 360]]); $bars = fn (int $row): array => array_map(fn ($bar) => [$bar->task->taskId, $bar->start, $bar->span, $bar->lane, $bar->late], $rows[$row]->bars); expect($bars(0))->toBe([[1, 0, 2, 0, false], [2, 1, 1, 1, false], [3, 2, 2, 0, true]]) ->and($rows[0]->lanes)->toBe(2) ->and($rows[0]->minutesByDay)->toBe(['2026-12-07' => 0, '2026-12-08' => 360, '2026-12-09' => 0, '2026-12-10' => 0]) ->and($bars(1))->toBe([[1, 0, 3, 0, false]]) ->and($bars(2))->toBe([[4, 0, 1, 0, false]]) ->and(array_map(fn ($bar) => $bar->task->taskId, $rows[0]->barsOn(1)))->toBe([1, 2]); });