Files
animethemes-server/tests/Feature/Http/Api/Auth/User/Me/MyShowTest.php
T
paranarimasuandGitHub 2e930b17ff feat: initial migration to Laravel 10 (#572)
* feat: initial migration to Laravel 10

* style: fix StyleCI findings
2023-04-18 16:22:36 -05:00

58 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Http\Api\Auth\User\Me;
use App\Http\Api\Query\Query;
use App\Http\Resources\Auth\Resource\UserResource;
use App\Models\Auth\User;
use Illuminate\Foundation\Testing\WithFaker;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
/**
* Class MyShowTest.
*/
class MyShowTest extends TestCase
{
use WithFaker;
/**
* The My Show Endpoint shall be protected by sanctum.
*
* @return void
*/
public function testProtected(): void
{
$response = $this->get(route('api.me.show'));
$response->assertUnauthorized();
}
/**
* The My Show Endpoint shall return the resource of the current user.
*
* @return void
*/
public function testDefault(): void
{
$user = User::factory()->createOne();
Sanctum::actingAs($user);
$response = $this->get(route('api.me.show'));
$response->assertJson(
json_decode(
json_encode(
(new UserResource($user, new Query()))
->response()
->getData()
),
true
)
);
}
}