Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions routes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
Route::get('register', [RegisteredUserController::class, 'create'])
->name('register');

Route::post('register', [RegisteredUserController::class, 'store']);
Route::post('register', [RegisteredUserController::class, 'store'])
->name('register.store');

Route::get('login', [AuthenticatedSessionController::class, 'create'])
->name('login');

Route::post('login', [AuthenticatedSessionController::class, 'store']);
Route::post('login', [AuthenticatedSessionController::class, 'store'])
->name('login.store');

Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
->name('password.request');
Expand Down Expand Up @@ -50,7 +52,8 @@
->name('password.confirm');

Route::post('confirm-password', [ConfirmablePasswordController::class, 'store'])
->middleware('throttle:6,1');
->middleware('throttle:6,1')
->name('password.confirm.store');

Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])
->name('logout');
Expand Down
14 changes: 7 additions & 7 deletions tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AuthenticationTest extends TestCase

public function test_login_screen_can_be_rendered()
{
$response = $this->get('/login');
$response = $this->get(route('login'));

$response->assertStatus(200);
}
Expand All @@ -21,7 +21,7 @@ public function test_users_can_authenticate_using_the_login_screen()
{
$user = User::factory()->create();

$response = $this->post('/login', [
$response = $this->post(route('login'), [
'email' => $user->email,
'password' => 'password',
]);
Expand All @@ -34,7 +34,7 @@ public function test_users_can_not_authenticate_with_invalid_password()
{
$user = User::factory()->create();

$this->post('/login', [
$this->post(route('login.store'), [
'email' => $user->email,
'password' => 'wrong-password',
]);
Expand All @@ -46,26 +46,26 @@ public function test_users_can_logout()
{
$user = User::factory()->create();

$response = $this->actingAs($user)->post('/logout');
$response = $this->actingAs($user)->post(route('logout'));

$this->assertGuest();
$response->assertRedirect('/');
$response->assertRedirect(route('home'));
}

public function test_users_are_rate_limited()
{
$user = User::factory()->create();

for ($i = 0; $i < 5; $i++) {
$this->post('/login', [
$this->post(route('login'), [
'email' => $user->email,
'password' => 'wrong-password',
])->assertStatus(302)->assertSessionHasErrors([
'email' => 'These credentials do not match our records.',
]);
}

$response = $this->post('/login', [
$response = $this->post(route('login'), [
'email' => $user->email,
'password' => 'wrong-password',
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Auth/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function test_email_verification_screen_can_be_rendered()
{
$user = User::factory()->unverified()->create();

$response = $this->actingAs($user)->get('/verify-email');
$response = $this->actingAs($user)->get(route('verification.notice'));

$response->assertStatus(200);
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public function test_verified_user_is_redirected_to_dashboard_from_verification_
'email_verified_at' => now(),
]);

$response = $this->actingAs($user)->get('/verify-email');
$response = $this->actingAs($user)->get(route('verification.notice'));

$response->assertRedirect(route('dashboard', absolute: false));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Auth/PasswordConfirmationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function test_confirm_password_screen_can_be_rendered()
{
$user = User::factory()->create();

$response = $this->actingAs($user)->get('/confirm-password');
$response = $this->actingAs($user)->get(route('password.confirm'));

$response->assertStatus(200);
}
Expand All @@ -23,7 +23,7 @@ public function test_password_can_be_confirmed()
{
$user = User::factory()->create();

$response = $this->actingAs($user)->post('/confirm-password', [
$response = $this->actingAs($user)->post(route('password.confirm.store'), [
'password' => 'password',
]);

Expand All @@ -35,7 +35,7 @@ public function test_password_is_not_confirmed_with_invalid_password()
{
$user = User::factory()->create();

$response = $this->actingAs($user)->post('/confirm-password', [
$response = $this->actingAs($user)->post(route('password.confirm.store'), [
'password' => 'wrong-password',
]);

Expand Down
14 changes: 7 additions & 7 deletions tests/Feature/Auth/PasswordResetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PasswordResetTest extends TestCase

public function test_reset_password_link_screen_can_be_rendered()
{
$response = $this->get('/forgot-password');
$response = $this->get(route('password.request'));

$response->assertStatus(200);
}
Expand All @@ -25,7 +25,7 @@ public function test_reset_password_link_can_be_requested()

$user = User::factory()->create();

$this->post('/forgot-password', ['email' => $user->email]);
$this->post(route('password.email'), ['email' => $user->email]);

Notification::assertSentTo($user, ResetPassword::class);
}
Expand All @@ -36,10 +36,10 @@ public function test_reset_password_screen_can_be_rendered()

$user = User::factory()->create();

$this->post('/forgot-password', ['email' => $user->email]);
$this->post(route('password.email'), ['email' => $user->email]);

Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
$response = $this->get('/reset-password/'.$notification->token);
$response = $this->get(route('password.request', $notification->token));

$response->assertStatus(200);

Expand All @@ -53,10 +53,10 @@ public function test_password_can_be_reset_with_valid_token()

$user = User::factory()->create();

$this->post('/forgot-password', ['email' => $user->email]);
$this->post(route('password.email'), ['email' => $user->email]);

Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
$response = $this->post('/reset-password', [
$response = $this->post(route('password.store'), [
'token' => $notification->token,
'email' => $user->email,
'password' => 'password',
Expand All @@ -75,7 +75,7 @@ public function test_password_cannot_be_reset_with_invalid_token(): void
{
$user = User::factory()->create();

$response = $this->post('/reset-password', [
$response = $this->post(route('password.store'), [
'token' => 'invalid-token',
'email' => $user->email,
'password' => 'newpassword123',
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class RegistrationTest extends TestCase

public function test_registration_screen_can_be_rendered()
{
$response = $this->get('/register');
$response = $this->get(route('register'));

$response->assertStatus(200);
}

public function test_new_users_can_register()
{
$response = $this->post('/register', [
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'email' => '[email protected]',
'password' => 'password',
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Auth/VerificationNotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function test_sends_verification_notification(): void
]);

$this->actingAs($user)
->post('email/verification-notification')
->assertRedirect('/');
->post(route('verification.send'))
->assertRedirect(route('home'));

Notification::assertSentTo($user, VerifyEmail::class);
}
Expand All @@ -36,7 +36,7 @@ public function test_does_not_send_verification_notification_if_email_is_verifie
]);

$this->actingAs($user)
->post('email/verification-notification')
->post(route('verification.send'))
->assertRedirect(route('dashboard', absolute: false));

Notification::assertNothingSent();
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/DashboardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ class DashboardTest extends TestCase

public function test_guests_are_redirected_to_the_login_page()
{
$response = $this->get('/dashboard');
$response->assertRedirect('/login');
$response = $this->get(route('dashboard'));
$response->assertRedirect(route('login'));
}

public function test_authenticated_users_can_visit_the_dashboard()
{
$user = User::factory()->create();
$this->actingAs($user);

$response = $this->get('/dashboard');
$response = $this->get(route('dashboard'));
$response->assertStatus(200);
}
}
2 changes: 1 addition & 1 deletion tests/Feature/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ExampleTest extends TestCase

public function test_returns_a_successful_response()
{
$response = $this->get('/');
$response = $this->get(route('home'));

$response->assertStatus(200);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Feature/Settings/PasswordUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function test_password_update_page_is_displayed()

$response = $this
->actingAs($user)
->get('/settings/password');
->get(route('password.edit'));

$response->assertStatus(200);
}
Expand All @@ -28,16 +28,16 @@ public function test_password_can_be_updated()

$response = $this
->actingAs($user)
->from('/settings/password')
->put('/settings/password', [
->from(route('password.edit'))
->put(route('password.update'), [
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);

$response
->assertSessionHasNoErrors()
->assertRedirect('/settings/password');
->assertRedirect(route('password.edit'));

$this->assertTrue(Hash::check('new-password', $user->refresh()->password));
}
Expand All @@ -48,15 +48,15 @@ public function test_correct_password_must_be_provided_to_update_password()

$response = $this
->actingAs($user)
->from('/settings/password')
->put('/settings/password', [
->from(route('password.edit'))
->put(route('password.update'), [
'current_password' => 'wrong-password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);

$response
->assertSessionHasErrors('current_password')
->assertRedirect('/settings/password');
->assertRedirect(route('password.edit'));
}
}
20 changes: 10 additions & 10 deletions tests/Feature/Settings/ProfileUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function test_profile_page_is_displayed()

$response = $this
->actingAs($user)
->get('/settings/profile');
->get(route('profile.edit'));

$response->assertOk();
}
Expand All @@ -27,14 +27,14 @@ public function test_profile_information_can_be_updated()

$response = $this
->actingAs($user)
->patch('/settings/profile', [
->patch(route('profile.update'), [
'name' => 'Test User',
'email' => '[email protected]',
]);

$response
->assertSessionHasNoErrors()
->assertRedirect('/settings/profile');
->assertRedirect(route('profile.edit'));

$user->refresh();

Expand All @@ -49,14 +49,14 @@ public function test_email_verification_status_is_unchanged_when_the_email_addre

$response = $this
->actingAs($user)
->patch('/settings/profile', [
->patch(route('profile.update'), [
'name' => 'Test User',
'email' => $user->email,
]);

$response
->assertSessionHasNoErrors()
->assertRedirect('/settings/profile');
->assertRedirect(route('profile.edit'));

$this->assertNotNull($user->refresh()->email_verified_at);
}
Expand All @@ -67,13 +67,13 @@ public function test_user_can_delete_their_account()

$response = $this
->actingAs($user)
->delete('/settings/profile', [
->delete(route('profile.destroy'), [
'password' => 'password',
]);

$response
->assertSessionHasNoErrors()
->assertRedirect('/');
->assertRedirect(route('home'));

$this->assertGuest();
$this->assertNull($user->fresh());
Expand All @@ -85,14 +85,14 @@ public function test_correct_password_must_be_provided_to_delete_account()

$response = $this
->actingAs($user)
->from('/settings/profile')
->delete('/settings/profile', [
->from(route('profile.edit'))
->delete(route('profile.destroy'), [
'password' => 'wrong-password',
]);

$response
->assertSessionHasErrors('password')
->assertRedirect('/settings/profile');
->assertRedirect(route('profile.edit'));

$this->assertNotNull($user->fresh());
}
Expand Down