28 lines
870 B
PHP
28 lines
870 B
PHP
<?php
|
|
|
|
namespace Tests\Feature\Permission;
|
|
|
|
use App\User;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Tests\TestCase;
|
|
|
|
class UserIndexTest extends TestCase
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
public function testItListsUsers(): void
|
|
{
|
|
$this->login()->loginNami();
|
|
auth()->user()->update(['firstname' => 'Jane', 'lastname' => 'Doe']);
|
|
User::factory()->create(['firstname' => 'John', 'lastname' => 'Doe']);
|
|
$anna = User::factory()->create(['firstname' => 'Anna', 'lastname' => 'Doe']);
|
|
$this->get(route('api.user.index'))
|
|
->assertJsonPath('data.0.firstname', 'Anna')
|
|
->assertJsonPath('data.0.lastname', 'Doe')
|
|
->assertJsonPath('data.0.id', $anna->id)
|
|
->assertJsonPath('data.1.firstname', 'Jane')
|
|
->assertJsonPath('data.2.firstname', 'John');
|
|
}
|
|
}
|