<?php

declare(strict_types=1);

use App\Models\User;
use BezhanSalleh\FilamentShield\Support\Utils;
use Database\Seeders\RoleSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

uses(TestCase::class, RefreshDatabase::class)->in('Feature', 'Unit');

function seedRoles(): void
{
    (new RoleSeeder)->run();
}

function createAdminUser(array $attributes = []): User
{
    seedRoles();

    $user = User::factory()->create($attributes);
    $user->assignRole(Utils::getSuperAdminName());

    return $user;
}

function createUserWithRole(string $role, array $attributes = []): User
{
    seedRoles();

    $user = User::factory()->create($attributes);
    $user->assignRole($role);

    return $user;
}
