Перевод на доменную архитектуру

This commit is contained in:
brusnitsyn
2026-04-26 23:37:50 +09:00
parent 75ca01ffd8
commit f107ebd167
70 changed files with 4656 additions and 2070 deletions

View 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);