feat: include testing, factories, git workflow for testing.
All checks were successful
Tests / Laravel tests (pull_request) Successful in 3m31s
All checks were successful
Tests / Laravel tests (pull_request) Successful in 3m31s
This commit is contained in:
19
tests/Feature/Controllers/ProfileControllerTest.php
Normal file
19
tests/Feature/Controllers/ProfileControllerTest.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
test('guests cannot access profile management routes', function () {
|
||||
$this->get(route('profile.edit'))->assertRedirect(route('login'));
|
||||
$this->patch(route('profile.update'), [])->assertRedirect(route('login'));
|
||||
$this->delete(route('profile.destroy'), [])->assertRedirect(route('login'));
|
||||
});
|
||||
|
||||
test('the profile edit page receives the authenticated user', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('profile.edit'))
|
||||
->assertOk()
|
||||
->assertViewIs('profile.edit')
|
||||
->assertViewHas('user', fn (User $viewUser) => $viewUser->is($user));
|
||||
});
|
||||
Reference in New Issue
Block a user