50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Auth;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Notifications\ResetPassword;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Notification;
|
|
use Tests\TestCase;
|
|
|
|
class PasswordResetLinkControllerTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_forgot_password_screen_can_be_rendered(): void
|
|
{
|
|
$response = $this->get('/forgot-password');
|
|
|
|
$response->assertStatus(200);
|
|
}
|
|
|
|
public function test_password_reset_link_can_be_requested(): void
|
|
{
|
|
Notification::fake();
|
|
$user = User::factory()->create();
|
|
|
|
$this->post('/forgot-password', ['email' => $user->email]);
|
|
|
|
Notification::assertSentTo($user, ResetPassword::class);
|
|
}
|
|
|
|
public function test_password_reset_link_fails_with_invalid_email(): void
|
|
{
|
|
$response = $this->post('/forgot-password', [
|
|
'email' => 'nonexistent@example.com',
|
|
]);
|
|
|
|
$response->assertSessionHasErrors('email');
|
|
}
|
|
|
|
public function test_password_reset_link_validates_email(): void
|
|
{
|
|
$response = $this->post('/forgot-password', [
|
|
'email' => '',
|
|
]);
|
|
|
|
$response->assertSessionHasErrors('email');
|
|
}
|
|
}
|