28 lines
744 B
PHP
28 lines
744 B
PHP
<?php
|
|
|
|
use App\Mail\ResetPassword;
|
|
use App\Models\User;
|
|
|
|
test('test send password reminder', function () {
|
|
$this->setSettings(['forgot_password' => true]);
|
|
|
|
Mail::fake();
|
|
|
|
$user = User::factory()->create(['email' => 'test@test.com']);
|
|
|
|
$this->postJson('api/password/remind', ['email' => 'test@test.com'])
|
|
->assertOk();
|
|
|
|
Mail::assertQueued(ResetPassword::class, function ($mail) use ($user) {
|
|
return $mail->hasTo($user->email);
|
|
});
|
|
});
|
|
|
|
test('test password reminder with wrong email', function () {
|
|
$this->setSettings(['forgot_password' => true]);
|
|
|
|
$this->postJson('api/password/remind', ['email' => 'test@test.com'])
|
|
->assertStatus(422)
|
|
->assertJsonValidationErrors('email');
|
|
});
|