<?php

app_require('routes/moduleWorkfeedRoute.php');

use routes\moduleWorkfeedRoute;

function workfeed_route_invoke_private(moduleWorkfeedRoute $route, string $method, array $args = []): mixed
{
    $reflection = new ReflectionClass($route);
    $target = $reflection->getMethod($method);

    return $target->invokeArgs($route, $args);
}

it('filters request parameters down to the allowed workfeed query keys', function (): void {
    $_SERVER['REQUEST_URI'] = '/modules/workfeed/shifts';
    $route = new moduleWorkfeedRoute();

    $filtered = workfeed_route_invoke_private($route, 'filterRequestParameters', [[
        'startFrom' => '2026-03-24T00:00:00.000Z',
        'startTo' => '2026-03-25T00:00:00.000Z',
        'employeeID' => 'emp_123',
        'released' => 'true',
        'ignored' => 'value',
    ], [
        'startFrom',
        'startTo',
        'employeeID',
        'released',
    ]]);

    expect($filtered)->toBe([
        'startFrom' => '2026-03-24T00:00:00.000Z',
        'startTo' => '2026-03-25T00:00:00.000Z',
        'employeeID' => 'emp_123',
        'released' => 'true',
    ]);
});
