37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Domain\Reports\Models\ReportSnapshot;
|
|
|
|
it('normalizes metrics and exposes comparable payload', function () {
|
|
$snapshot = new ReportSnapshot(
|
|
departmentId: 10,
|
|
userId: 5015,
|
|
actorUserId: 15,
|
|
periodStart: new DateTimeImmutable('2026-04-08 06:00:00'),
|
|
periodEnd: new DateTimeImmutable('2026-04-09 06:00:00'),
|
|
status: 'submitted',
|
|
autoFill: true,
|
|
metrics: [
|
|
'metrika_item_12' => 7,
|
|
4 => 11,
|
|
],
|
|
observationPatients: [['medical_history_id' => 100]],
|
|
unwantedEvents: [['title' => 'Event']],
|
|
);
|
|
|
|
expect($snapshot->normalizedMetrics())->toBe([
|
|
4 => 11,
|
|
12 => 7,
|
|
])->and($snapshot->toComparableArray()['auto_fill'])->toBeTrue();
|
|
});
|
|
|
|
it('rejects invalid period ranges', function () {
|
|
new ReportSnapshot(
|
|
departmentId: 10,
|
|
userId: 5015,
|
|
actorUserId: 15,
|
|
periodStart: new DateTimeImmutable('2026-04-09 06:00:00'),
|
|
periodEnd: new DateTimeImmutable('2026-04-08 06:00:00'),
|
|
);
|
|
})->throws(InvalidArgumentException::class);
|