From 4dfcde99bac559efebbc7d646427d0329bb31c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 4 Jun 2026 03:54:22 +0300 Subject: [PATCH] fix(imitation): correct seedPhoneRange columns + import_id FK (F1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../Support/Imitation/ImitationTestCase.php | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/app/tests/Support/Imitation/ImitationTestCase.php b/app/tests/Support/Imitation/ImitationTestCase.php index 66be7ec3..76001078 100644 --- a/app/tests/Support/Imitation/ImitationTestCase.php +++ b/app/tests/Support/Imitation/ImitationTestCase.php @@ -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, ]); } }