<?php

declare(strict_types=1);

use App\Models\User;
use App\Models\UserProfile;
use Database\Seeders\RoleAndPermissionSeeder;

beforeEach(function (): void {
    $this->seed(RoleAndPermissionSeeder::class);
});

it('has correct fillable attributes', function (): void {
    $user = new User;

    expect($user->getFillable())->toBe([
        'name', 'email', 'password', 'status', 'phone', 'company', 'admin_notes', 'virtfusion_user_id',
        'override_days_to_suspend', 'override_days_to_terminate', 'credit_balance', 'currency',
    ]);
});

it('has correct hidden attributes', function (): void {
    $user = new User;

    expect($user->getHidden())->toBe([
        'password', 'remember_token', 'two_factor_secret', 'two_factor_recovery_codes',
    ]);
});

it('has profile relationship', function (): void {
    $user = User::factory()->create();
    $profile = UserProfile::factory()->create(['user_id' => $user->id]);

    expect($user->profile)->toBeInstanceOf(UserProfile::class);
    expect($user->profile->id)->toBe($profile->id);
});

it('creates user with factory', function (): void {
    $user = User::factory()->create();

    expect($user)->toBeInstanceOf(User::class);
    expect($user->status)->toBe('active');
});
