36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
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 testItOpensSettingsPage(): void
|
|
{
|
|
$this->login()->loginNami();
|
|
$this->get(route('setting.view', ['settingGroup' => 'user']))
|
|
->assertOk()
|
|
->assertComponent('setting/User');
|
|
}
|
|
|
|
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');
|
|
}
|
|
}
|