<?php

namespace Tests\Feature\Integration;

use App\Models\User;
use Database\Seeders\RolesAndPermissionsSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class RemainingFeaturesTest extends TestCase
{
    use RefreshDatabase;

    protected function setUp(): void
    {
        parent::setUp();
        $this->seed(RolesAndPermissionsSeeder::class);
    }

    public function test_login_creates_audit_log(): void
    {
        $user = User::factory()->create(['password' => bcrypt('password')]);
        $user->assignRole('Administrator');

        $this->post(route('login'), ['email' => $user->email, 'password' => 'password']);

        $this->assertDatabaseHas('login_logs', ['user_id' => $user->id, 'event' => 'login']);
    }
}
