Files
econom-calculator/tests/Feature/FinanceStructureTest.php
brusnitsyn 3edc8e667e
Some checks failed
tests / ci (8.5) (push) Has been cancelled
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
first commit
2026-04-03 17:20:05 +09:00

86 lines
2.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use App\Models\Department;
use App\Models\HospitalUnit;
use App\Models\Profile;
use Database\Seeders\DepartmentSeeder;
use Database\Seeders\HospitalUnitSeeder;
use Database\Seeders\ProfileSeeder;
test('finance profiles and hospital units are seeded from configured structure', function () {
$this->seed([
ProfileSeeder::class,
HospitalUnitSeeder::class,
]);
expect(Profile::query()->orderBy('sort_order')->pluck('name')->all())->toBe([
'Терапевтический',
'Хирургический',
'ОПЦ',
'РСЦ',
'Реанимации',
'Прочие',
]);
$unit = HospitalUnit::query()
->where('name', 'Рентгенологическое отделение')
->first();
expect($unit)->not->toBeNull();
expect($unit?->profile?->name)->toBe('Прочие');
expect($unit?->is_reporting_unit)->toBeTrue();
expect($unit?->report_input_type)->toBe('sectioned_department_metrics');
});
test('non-reporting finance rows remain in the structure but are not marked as reporting units', function () {
$this->seed([
ProfileSeeder::class,
HospitalUnitSeeder::class,
]);
$unit = HospitalUnit::query()
->where('name', 'Сотрудники')
->first();
expect($unit)->not->toBeNull();
expect($unit?->profile?->name)->toBe('Прочие');
expect($unit?->is_reporting_unit)->toBeFalse();
expect($unit?->report_input_type)->toBeNull();
});
test('department abbreviations are mapped to finance hospital units where configured', function () {
$this->seed([
ProfileSeeder::class,
HospitalUnitSeeder::class,
DepartmentSeeder::class,
]);
$department = Department::query()
->where('name', 'Гематология')
->first();
expect($department)->not->toBeNull();
expect($department?->hospitalUnit?->name)->toBe('Гематологическое отделение');
$adultClinic = Department::query()
->where('name', 'П-ка взрослая')
->first();
expect($adultClinic)->not->toBeNull();
expect($adultClinic?->hospitalUnit?->name)->toBe('Областная консультативно-диагностическая поликлиника');
$intensiveCare = Department::query()
->where('name', 'РАО 1')
->first();
expect($intensiveCare)->not->toBeNull();
expect($intensiveCare?->hospitalUnit?->name)->toBe('Отделение анестезиологии-реанимации с палатами реанимации и интенсивной терапии');
$pathology = Department::query()
->where('name', 'ПАО')
->first();
expect($pathology)->not->toBeNull();
expect($pathology?->hospitalUnit?->name)->toBe('Патологоанатомическое отделение');
});