fix(imitation): correct seedPhoneRange columns + import_id FK (F1)

ImitationTestCase::seedPhoneRange used non-existent columns (range_from/range_to/region_name) and omitted the required import_id FK, so every Россвязь-branch test that called it failed. Now seeds a phone_ranges_imports anchor row and inserts phone_ranges with the real columns (def_code/from_num/to_num/operator/region/subject_code/imported_at/import_id), mirroring the verified RossvyazPrefixLookup parsing. Found during Task 5.
This commit is contained in:
Дмитрий
2026-06-04 03:54:22 +03:00
parent f55c224d6a
commit 4dfcde99ba
@@ -84,19 +84,35 @@ abstract class ImitationTestCase extends TestCase
* Use App\Support\RussianRegions::nameToCode() for lookup.
*/
protected function seedPhoneRange(
string $defCode,
string $from,
string $to,
int $defCode,
int $from,
int $to,
int $subjectCode,
): void {
// Anchor phone_ranges_imports row first — phone_ranges.import_id is a
// required FK (migration 2026_05_31_100000). F1 fix: the previous version
// used non-existent columns (range_from/range_to/region_name) and omitted
// import_id, so every Россвязь-branch test that called it failed at runtime.
$importId = DB::table('phone_ranges_imports')->insertGetId([
'imported_at' => now(),
'source_url' => 'test://rossvyaz',
'rows_inserted' => 1,
'rows_updated' => 0,
'checksum_sha256' => str_repeat('0', 64),
'status' => 'completed',
'completed_at' => now(),
]);
DB::table('phone_ranges')->insert([
'def_code' => $defCode,
'range_from' => $from,
'range_to' => $to,
'subject_code' => $subjectCode,
'region_name' => '',
'operator' => 'test-operator',
'imported_at' => now(),
'def_code' => $defCode,
'from_num' => $from,
'to_num' => $to,
'operator' => 'test-operator',
'region' => \App\Support\RussianRegions::CODE_TO_NAME[$subjectCode] ?? 'test-region',
'region_normalized' => null,
'subject_code' => $subjectCode,
'imported_at' => now(),
'import_id' => $importId,
]);
}
}