<?php

declare(strict_types=1);

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

final class TestCategorySeeder extends Seeder
{
    /**
     * Seed a minimal test category with one question group and five scored questions for quick testing.
     */
    public function run(): void
    {
        $categoryId = DB::table('categories')->insertGetId([
            'name' => 'Test',
            'sort_order' => 99,
            'created_at' => now(),
            'updated_at' => now(),
        ]);

        $groupId = DB::table('question_groups')->insertGetId([
            'category_id' => $categoryId,
            'name' => 'Test Group',
            'sort_order' => 1,
            'description' => null,
            'scoring_instructions' => null,
            'created_at' => now(),
            'updated_at' => now(),
        ]);

        $questions = [];
        for ($i = 1; $i <= 5; $i++) {
            $questions[] = [
                'question_group_id' => $groupId,
                'text' => "Test question {$i}",
                'has_yes' => true,
                'has_no' => true,
                'has_na' => true,
                'details' => 'optional',
                'sort_order' => $i,
                'is_scored' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ];
        }

        DB::table('questions')->insert($questions);
    }
}
