<?php

namespace Tests\Feature;

use App\Enums\MatchStatus;
use App\Models\Fixture;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class FixtureDefaultsTest extends TestCase
{
    use RefreshDatabase;

    public function test_fixture_creation_defaults_lock_time_and_status(): void
    {
        $homeTeam = Team::create([
            'name' => 'Mexico',
            'short_name' => 'Mexico',
            'slug' => 'mexico',
            'fifa_code' => 'MEX',
        ]);

        $awayTeam = Team::create([
            'name' => 'Canada',
            'short_name' => 'Canada',
            'slug' => 'canada',
            'fifa_code' => 'CAN',
        ]);

        $fixture = Fixture::create([
            'home_team_id' => $homeTeam->id,
            'away_team_id' => $awayTeam->id,
            'stage' => 'Group Stage',
            'venue' => 'Estadio BBVA',
            'starts_at' => '2026-06-11 20:00:00',
        ]);

        $this->assertSame('2026-06-11 19:45:00', $fixture->picks_lock_at?->format('Y-m-d H:i:s'));
        $this->assertSame(MatchStatus::Scheduled, $fixture->status);
        $this->assertNull($fixture->home_score);
        $this->assertNull($fixture->away_score);
        $this->assertNull($fixture->result);
        $this->assertNull($fixture->result_declared_at);
    }
}
