2023-09-08 00:29:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Authentication;
|
|
|
|
|
|
|
|
use App\Auth\ResetPassword;
|
|
|
|
use App\User;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Illuminate\Support\Facades\Notification;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class ForgotPasswordTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItShowsResetForm(): void
|
|
|
|
{
|
|
|
|
$this->withoutExceptionHandling();
|
2024-06-27 17:50:18 +02:00
|
|
|
$this->get('/password/reset')->assertComponent('authentication/PasswordReset');
|
2023-09-08 00:29:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testItRequiresAnEmailAddress(): void
|
|
|
|
{
|
|
|
|
$this->postJson('/password/email')->assertJsonValidationErrors(['email' => 'E-Mail Adresse ist erforderlich.']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItNeedsAnActiveUser(): void
|
|
|
|
{
|
|
|
|
$this->postJson('/password/email', [
|
|
|
|
'email' => 'test@aa.de',
|
|
|
|
])->assertJsonValidationErrors(['email' => 'Es konnte leider kein Nutzer mit dieser E-Mail-Adresse gefunden werden.']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItSendsPasswordResetLink(): void
|
|
|
|
{
|
|
|
|
Notification::fake();
|
|
|
|
|
|
|
|
$user = User::factory()->create(['email' => 'test@aa.de']);
|
|
|
|
$this->postJson('/password/email', [
|
|
|
|
'email' => 'test@aa.de',
|
|
|
|
])->assertOk();
|
|
|
|
|
|
|
|
Notification::assertSentTo($user, ResetPassword::class);
|
|
|
|
}
|
|
|
|
}
|