From 71d0005193a56a686baa618370b60116a4a59a52 Mon Sep 17 00:00:00 2001 From: Peter Papp Date: Sun, 14 Mar 2021 11:26:35 +0100 Subject: [PATCH] added it_send_reset_link_to_email, it_reset_user_passwordtest --- config/fortify.php | 4 +-- tests/Feature/Accounts/AuthTest.php | 44 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/config/fortify.php b/config/fortify.php index b741525d..b76f3538 100644 --- a/config/fortify.php +++ b/config/fortify.php @@ -133,10 +133,10 @@ return [ 'features' => [ Features::registration(), - Features::resetPasswords(), + //Features::resetPasswords(), // Features::emailVerification(), Features::updateProfileInformation(), - Features::updatePasswords(), + //Features::updatePasswords(), /*Features::twoFactorAuthentication([ 'confirmPassword' => true, ]),*/ diff --git a/tests/Feature/Accounts/AuthTest.php b/tests/Feature/Accounts/AuthTest.php index cb15f521..0e2876b7 100644 --- a/tests/Feature/Accounts/AuthTest.php +++ b/tests/Feature/Accounts/AuthTest.php @@ -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, + ]); + } }