user list
This commit is contained in:
25
tests/Feature/UserIndexTest.php
Normal file
25
tests/Feature/UserIndexTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
test('guests are redirected to login from users page', function () {
|
||||
$this->get('/users')->assertRedirect('/login');
|
||||
});
|
||||
|
||||
test('authenticated users can view the users page', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get('/users')
|
||||
->assertOk()
|
||||
->assertViewIs('users.index');
|
||||
});
|
||||
|
||||
test('users page lists all users', function () {
|
||||
$users = User::factory()->count(3)->create();
|
||||
|
||||
$this->actingAs($users->first())
|
||||
->get('/users')
|
||||
->assertOk()
|
||||
->assertViewHas('users', fn ($viewUsers) => $viewUsers->count() === User::count());
|
||||
});
|
||||
Reference in New Issue
Block a user