Enhance department weather timeline API: support multiple IDs, add timeline date override, improve ID parsing, update schema examples, and expand related tests.

This commit is contained in:
Jeppe Bundgaard
2026-03-24 13:06:40 +01:00
parent c714af6c9e
commit 228efb74fb
4 changed files with 312 additions and 64 deletions
@@ -86,3 +86,36 @@ it('normalizes wrapped workfeed collections from common response keys', function
expect($items[1]->id ?? null)->toBe('b');
});
it('calculates workfeed employee hours across multiple departments for one hour slot', function (): void {
$route = new moduleWeatherAPIRoute();
$slot = new DateTime('2026-03-24T13:00:00+00:00');
$shifts = [
(object)[
'departmentID' => 'dep_1',
'start' => '2026-03-24T13:00:00+00:00',
'end' => '2026-03-24T14:00:00+00:00',
],
(object)[
'departmentID' => 'dep_2',
'start' => '2026-03-24T13:00:00+00:00',
'end' => '2026-03-24T14:00:00+00:00',
],
];
$hours = weather_route_invoke_private($route, 'calculateWorkfeedEmployeeHoursForHour', [$shifts, ['dep_1', 'dep_2'], $slot]);
expect($hours)->toBe(2.0);
});
it('normalizes department id input from scalar csv and nested array values', function (): void {
$route = new moduleWeatherAPIRoute();
$single = weather_route_invoke_private($route, 'normalizeDepartmentIdInput', ['7']);
$csv = weather_route_invoke_private($route, 'normalizeDepartmentIdInput', ['1, 2,3']);
$nested = weather_route_invoke_private($route, 'normalizeDepartmentIdInput', [[1, '2,3', [4, '5']]]);
expect($single)->toBe(['7']);
expect($csv)->toBe(['1', '2', '3']);
expect($nested)->toBe([1, '2', '3', 4, '5']);
});