<?php

namespace Tests\Feature\Migrations;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class AddScannerCategoryValidationToTenantsTest extends TestCase
{
    use RefreshDatabase;

    public function test_it_disables_scanner_category_validation_only_for_desfile(): void
    {
        $migration = require database_path(
            'migrations/2026_08_13_020000_add_scanner_category_validation_to_tenants_table.php'
        );

        $migration->down();
        $migration->up();

        $this->assertDatabaseHas('tenants', [
            'codigo' => 'desfile_pura_tendencia',
            'scanner_category_validation_enabled' => false,
        ]);

        DB::table('tenants')->insert([
            'codigo' => 'scanner-validation-default',
            'nombre' => 'Scanner validation default',
            'dominio' => 'scanner-validation-default.test',
        ]);

        $this->assertDatabaseHas('tenants', [
            'codigo' => 'scanner-validation-default',
            'scanner_category_validation_enabled' => true,
        ]);
    }
}
