adrema/tests/Feature/Permission/UserIndexTest.php

28 lines
870 B
PHP
Raw Normal View History

2024-07-31 22:47:04 +02:00
<?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');
}
}