['traffic'], 'timestamp' => ['step' => 1800], 'values' => [[100 => 2.0, 1900 => 3.0]], ]; }); test('bandwidth summation uses the interval observed in fetched rows', function () { expect(bandwidth_summation(1, 0, 3600, 300, 1))->toBe(['traffic' => 9000.0]); }); test('bandwidth summation falls back to the requested interval when one row cannot reveal a step', function () { $GLOBALS['bandwidth_fetch_result']['timestamp']['step'] = 0; expect(bandwidth_summation(1, 0, 3600, 300, 2))->toBe(['traffic' => 3000.0]); }); test('bandwidth summation handles empty names values and samples', function () { $GLOBALS['bandwidth_fetch_result'] = []; expect(bandwidth_summation(1, 0, 3600, 300, 1))->toBe([]); $GLOBALS['bandwidth_fetch_result'] = [ 'data_source_names' => ['missing', 'empty'], 'timestamp' => ['step' => 300], 'values' => [1 => []], ]; expect(bandwidth_summation(1, 0, 3600, 300, 1))->toBe(['empty' => 0]); });