first commit
This commit is contained in:
36
tests/Feature/Auth/MeTest.php
Normal file
36
tests/Feature/Auth/MeTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\Facades\UserFactory;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MeTest extends TestCase
|
||||
{
|
||||
private const URI = 'auth/me';
|
||||
|
||||
private User $user;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = UserFactory::withTokens()->create();
|
||||
}
|
||||
|
||||
public function test_me(): void
|
||||
{
|
||||
$response = $this->actingAs($this->user)->getJson(self::URI);
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJson(['user' => $this->user->toArray()]);
|
||||
}
|
||||
|
||||
public function test_without_auth(): void
|
||||
{
|
||||
$response = $this->getJson(self::URI);
|
||||
|
||||
$response->assertUnauthorized();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user