<?php

namespace Tests\Feature\V3\Profile;

use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;

class InfoTest extends TestCase
{
    use RefreshDatabase, WithFaker;

    public function test_user_info_returns_successfully(): void
    {
        $user = User::factory()->create();

        $this->actingAs($user);

        $response = $this->get(route('v3.profile.info'));

        $response->assertStatus(200);

        $response->assertExactJson([
            'data' => [
                'username' => $user->username,
                'first_name' => $user->first_name,
                'last_name' => $user->last_name,
                'name' => $user->name,
                'last_login' => $user->last_login,
                'major' => $user->major,
                'degree' => $user->degree,
                'mobile' => $user->mobile,
                # an accessor has been defined in User model for User's avatar
                'avatar' => URL::to('/') . '/' . $user->avatar,
            ]
        ]);
    }
}
