26 lines
655 B
PHP
26 lines
655 B
PHP
<?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());
|
|
});
|