Перевод на доменную архитектуру
This commit is contained in:
38
tests/Unit/Reports/PreoperativeDaysCalculatorTest.php
Normal file
38
tests/Unit/Reports/PreoperativeDaysCalculatorTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Reports\Calculators\PreoperativeDaysCalculator;
|
||||
use App\Domain\Reports\Models\OperationInterval;
|
||||
|
||||
it('calculates total and average preoperative days', function () {
|
||||
$calculator = new PreoperativeDaysCalculator;
|
||||
|
||||
$result = $calculator->calculate([
|
||||
new OperationInterval(
|
||||
admittedAt: new DateTimeImmutable('2026-04-01 10:00:00'),
|
||||
operationAt: new DateTimeImmutable('2026-04-03 09:00:00'),
|
||||
),
|
||||
new OperationInterval(
|
||||
admittedAt: new DateTimeImmutable('2026-04-05 10:00:00'),
|
||||
operationAt: new DateTimeImmutable('2026-04-06 09:00:00'),
|
||||
),
|
||||
]);
|
||||
|
||||
expect($result->total)->toBe(3)
|
||||
->and($result->count)->toBe(2)
|
||||
->and($result->average)->toBe(1.5);
|
||||
});
|
||||
|
||||
it('ignores invalid preoperative intervals', function () {
|
||||
$calculator = new PreoperativeDaysCalculator;
|
||||
|
||||
$result = $calculator->calculate([
|
||||
new OperationInterval(
|
||||
admittedAt: new DateTimeImmutable('2026-04-03 10:00:00'),
|
||||
operationAt: new DateTimeImmutable('2026-04-01 09:00:00'),
|
||||
),
|
||||
]);
|
||||
|
||||
expect($result->total)->toBe(0)
|
||||
->and($result->count)->toBe(0)
|
||||
->and($result->average)->toBe(0.0);
|
||||
});
|
||||
Reference in New Issue
Block a user