MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/snap.cafsinfotech.in/tests/Feature/Auth/RefreshTest.php
<?php

namespace Tests\Feature\Auth;

use App\Models\User;
use Tests\Facades\UserFactory;
use Tests\TestCase;

class RefreshTest extends TestCase
{
    private const URI = 'auth/refresh';
    private const TEST_URI = 'auth/me';

    private User $user;

    protected function setUp(): void
    {
        parent::setUp();

        $this->user = UserFactory::withTokens()->create();
    }

    public function test_refresh(): void
    {
        $token = cache("testing:{$this->user->id}:tokens");

        $this->assertNotEmpty($token);
        $this->assertNotEmpty($token[0]);
        $this->assertNotEmpty($token[0]['token']);

        $this->actingAs($token[0]['token'])->get(self::TEST_URI)->assertOk();

        $response = $this->actingAs($token[0]['token'])->postJson(self::URI);

        $response->assertOk();

        $this->actingAs($token[0]['token'])->get(self::TEST_URI)->assertUnauthorized();
    }
}