added it_send_reset_link_to_email, it_reset_user_passwordtest

This commit is contained in:
Peter Papp
2021-03-14 11:26:35 +01:00
parent 95eb167622
commit 71d0005193
2 changed files with 46 additions and 2 deletions

View File

@@ -133,10 +133,10 @@ return [
'features' => [
Features::registration(),
Features::resetPasswords(),
//Features::resetPasswords(),
// Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
//Features::updatePasswords(),
/*Features::twoFactorAuthentication([
'confirmPassword' => true,
]),*/

View File

@@ -4,8 +4,11 @@ namespace Tests\Feature\Accounts;
use App\Models\Setting;
use App\Models\User;
use App\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Password;
use Laravel\Sanctum\Sanctum;
use Notification;
use Storage;
use Tests\TestCase;
@@ -125,4 +128,45 @@ class AuthTest extends TestCase
$this->postJson('/logout')
->assertStatus(204);
}
/**
* @test
*/
public function it_send_reset_link_to_email()
{
Notification::fake();
$user = User::factory(User::class)
->create(['email' => 'john@doe.com']);
$this->postJson('/api/password/email', [
'email' => $user->email,
])->assertStatus(200);
Notification::assertTimesSent(1, ResetPassword::class);
}
/**
* @test
*/
public function it_reset_user_password()
{
$user = User::factory(User::class)
->create(['email' => 'john@doe.com']);
// Get password token
$token = Password::getRepository()
->create($user);
$this->postJson('/api/password/reset', [
'token' => $token,
'email' => $user->email,
'password' => 'VeryStrongPassword',
'password_confirmation' => 'VeryStrongPassword',
])->assertStatus(200);
$this->assertDatabaseMissing('password_resets', [
'email' => $user->email,
]);
}
}