Перевод на доменную архитектуру
This commit is contained in:
36
tests/Unit/Reports/ReportSnapshotTest.php
Normal file
36
tests/Unit/Reports/ReportSnapshotTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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);
|
||||
Reference in New Issue
Block a user