Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 6 additions & 7 deletions routes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,31 @@

use App\Http\Controllers\Auth\VerifyEmailController;
use Illuminate\Support\Facades\Route;
use Livewire\Volt\Volt;

Route::middleware('guest')->group(function (): void {
Volt::route('login', 'auth.login')
Route::get('login', \App\Livewire\Auth\Login::class)
->name('login');

Volt::route('register', 'auth.register')
Route::get('register', \App\Livewire\Auth\Register::class)
->name('register');

Volt::route('forgot-password', 'auth.forgot-password')
Route::get('forgot-password', \App\Livewire\Auth\ForgotPassword::class)
->name('password.request');

Volt::route('reset-password/{token}', 'auth.reset-password')
Route::get('reset-password/{token}', \App\Livewire\Auth\ResetPassword::class)
->name('password.reset');

});

Route::middleware('auth')->group(function (): void {
Volt::route('verify-email', 'auth.verify-email')
Route::get('verify-email', \App\Livewire\Auth\VerifyEmail::class)
->name('verification.notice');

Route::get('verify-email/{id}/{hash}', VerifyEmailController::class)
->middleware(['signed', 'throttle:6,1'])
->name('verification.verify');

Volt::route('confirm-password', 'auth.confirm-password')
Route::get('confirm-password', \App\Livewire\Auth\ConfirmPassword::class)
->name('password.confirm');
});

Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use App\Livewire\Auth\Login;
use App\Models\User;
use Livewire\Volt\Volt as LivewireVolt;
use Livewire\Livewire;

uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);

Expand All @@ -14,7 +15,7 @@
test('users can authenticate using the login screen', function (): void {
$user = User::factory()->create();

$response = LivewireVolt::test('auth.login')
$response = Livewire::test(Login::class)
->set('email', $user->email)
->set('password', 'password')
->call('login');
Expand Down
7 changes: 4 additions & 3 deletions tests/Feature/Auth/PasswordConfirmationTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use App\Livewire\Auth\ConfirmPassword;
use App\Models\User;
use Livewire\Volt\Volt;
use Livewire\Livewire;

uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);

Expand All @@ -18,7 +19,7 @@

$this->actingAs($user);

$response = Volt::test('auth.confirm-password')
$response = Livewire::test(ConfirmPassword::class)
->set('password', 'password')
->call('confirmPassword');

Expand All @@ -32,7 +33,7 @@

$this->actingAs($user);

$response = Volt::test('auth.confirm-password')
$response = Livewire::test(ConfirmPassword::class)
->set('password', 'wrong-password')
->call('confirmPassword');

Expand Down
20 changes: 11 additions & 9 deletions tests/Feature/Auth/PasswordResetTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

use App\Livewire\Auth\ForgotPassword;
use App\Livewire\Auth\ResetPassword;
use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
use Illuminate\Support\Facades\Notification;
use Livewire\Volt\Volt;
use Livewire\Livewire;

uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);

Expand All @@ -18,23 +20,23 @@

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

Volt::test('auth.forgot-password')
Livewire::test(ForgotPassword::class)
->set('email', $user->email)
->call('sendPasswordResetLink');

Notification::assertSentTo($user, ResetPassword::class);
Notification::assertSentTo($user, ResetPasswordNotification::class);
});

test('reset password screen can be rendered', function (): void {
Notification::fake();

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

Volt::test('auth.forgot-password')
Livewire::test(ForgotPassword::class)
->set('email', $user->email)
->call('sendPasswordResetLink');

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

$response->assertStatus(200);
Expand All @@ -48,12 +50,12 @@

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

Volt::test('auth.forgot-password')
Livewire::test(ForgotPassword::class)
->set('email', $user->email)
->call('sendPasswordResetLink');

Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user): true {
$response = Volt::test('auth.reset-password', ['token' => $notification->token])
Notification::assertSentTo($user, ResetPasswordNotification::class, function ($notification) use ($user): true {
$response = Livewire::test(ResetPassword::class, ['token' => $notification->token])
->set('email', $user->email)
->set('password', 'password')
->set('password_confirmation', 'password')
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Livewire\Volt\Volt;
use App\Livewire\Auth\Register;
use Livewire\Livewire;

uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);

Expand All @@ -11,7 +12,7 @@
});

test('new users can register', function (): void {
$response = Volt::test('auth.register')
$response = Livewire::test(Register::class)
->set('name', 'Test User')
->set('email', '[email protected]')
->set('password', 'password')
Expand Down