markTestSkipped('Excel template MafRegistry.xlsx not found'); } Storage::fake('public'); $user = User::factory()->create(); $year = (int) date('Y'); $order = Order::factory()->create([ 'year' => $year, 'name' => 'Площадка 1', ]); $product = Product::factory()->create([ 'year' => $year, 'article' => 'ART-001', 'nomenclature_number' => 'NOM-001', 'statement_name' => 'Наименование в ведомости', 'total_price' => 1234.56, ]); $targetSku = ProductSKU::factory() ->forOrder($order) ->forProduct($product) ->create([ 'year' => $year, 'statement_number' => 'STAT-001', 'statement_date' => '2026-05-19', 'upd_number' => null, ]); $blankStatementSku = ProductSKU::factory()->create([ 'year' => $year, 'statement_number' => ' ', 'upd_number' => null, ]); $alreadyExportedSku = ProductSKU::factory()->create([ 'year' => $year, 'statement_number' => 'STAT-002', 'upd_number' => 'OLD-UPD', ]); $link = (new ExportMafRegistryService())->handle($user->id, 'UPD-001', $year); $this->assertStringContainsString('/storage/export/maf-registry/', $link); $this->assertSame('UPD-001', $targetSku->fresh()->upd_number); $this->assertNull($blankStatementSku->fresh()->upd_number); $this->assertSame('OLD-UPD', $alreadyExportedSku->fresh()->upd_number); $file = File::query()->where('user_id', $user->id)->latest()->firstOrFail(); $this->assertTrue($file->is_generated); Storage::disk('public')->assertExists($file->path); $spreadsheet = IOFactory::load(Storage::disk('public')->path($file->path)); $sheet = $spreadsheet->getActiveSheet(); $this->assertSame('НАШ ДВОР', $sheet->getTitle()); $this->assertSame('Реестр оборудования и ведомостей "технической приемки" к УПД UPD-001', $sheet->getCell('C2')->getValue()); $this->assertSame('НАШ ДВОР', $sheet->getCell('A4')->getValue()); $this->assertSame('UPD-001', $sheet->getCell('C4')->getValue()); $this->assertSame('NOM-001', $sheet->getCell('D4')->getValue()); $this->assertSame('Наименование в ведомости', $sheet->getCell('E4')->getValue()); $this->assertSame('ART-001', $sheet->getCell('F4')->getValue()); $this->assertSame('STAT-001', $sheet->getCell('G4')->getValue()); $this->assertSame('Площадка 1', $sheet->getCell('I4')->getValue()); $this->assertSame(1, $sheet->getCell('M4')->getValue()); $this->assertSame(0, $sheet->getCell('N4')->getValue()); $this->assertSame(1234.56, $sheet->getCell('O4')->getValue()); $this->assertSame('С бетоном', $sheet->getCell('P4')->getValue()); $this->assertSame('=SUM(M4:M4)', $sheet->getCell('M1')->getValue()); $this->assertSame(0, $sheet->getCell('N1')->getValue()); $this->assertSame('=SUM(O4:O4)', $sheet->getCell('O1')->getValue()); } }