Перевод на доменную архитектуру
This commit is contained in:
38
tests/Unit/Reports/BedDaysCalculatorTest.php
Normal file
38
tests/Unit/Reports/BedDaysCalculatorTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Reports\Calculators\BedDaysCalculator;
|
||||
use App\Domain\Reports\Models\StayInterval;
|
||||
|
||||
it('calculates total and average bed days', function () {
|
||||
$calculator = new BedDaysCalculator;
|
||||
|
||||
$result = $calculator->calculate([
|
||||
new StayInterval(
|
||||
startAt: new DateTimeImmutable('2026-04-01 10:00:00'),
|
||||
endAt: new DateTimeImmutable('2026-04-04 09:00:00'),
|
||||
),
|
||||
new StayInterval(
|
||||
startAt: new DateTimeImmutable('2026-04-05 10:00:00'),
|
||||
endAt: new DateTimeImmutable('2026-04-07 09:00:00'),
|
||||
),
|
||||
]);
|
||||
|
||||
expect($result->total)->toBe(5)
|
||||
->and($result->count)->toBe(2)
|
||||
->and($result->average)->toBe(2.5);
|
||||
});
|
||||
|
||||
it('ignores invalid bed day intervals', function () {
|
||||
$calculator = new BedDaysCalculator;
|
||||
|
||||
$result = $calculator->calculate([
|
||||
new StayInterval(
|
||||
startAt: new DateTimeImmutable('2026-04-04 10:00:00'),
|
||||
endAt: 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