36 lines
866 B
PHP
36 lines
866 B
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use Tests\TestCase;
|
|
|
|
class UserAuthTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
/** @test */
|
|
public function authentificated_user_can_be_fetched()
|
|
{
|
|
$this->withoutExceptionHandling();
|
|
$this->actingAs($user = factory(User::class)->create(), 'api');
|
|
|
|
$response = $this->get('/api/auth-user');
|
|
|
|
$response->assertStatus(200)
|
|
->assertJson([
|
|
'data' => [
|
|
'user_id' => $user->id,
|
|
'attributes' => [
|
|
'name' => $user->name,
|
|
]
|
|
],
|
|
'links' => [
|
|
'self' => url('/users/'. $user->id),
|
|
]
|
|
]);
|
|
}
|
|
}
|