From 91eddb5d3262bb06ed1ce237ffc6f8d680053394 Mon Sep 17 00:00:00 2001 From: Mohammad Alavi Date: Sun, 12 Dec 2021 10:57:58 +0330 Subject: [PATCH] Add ResetPasswordActionTest --- .../Tests/Unit/ResetPasswordActionTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/Containers/AppSection/Authentication/Tests/Unit/ResetPasswordActionTest.php b/app/Containers/AppSection/Authentication/Tests/Unit/ResetPasswordActionTest.php index 92dc26cc2..5aa92872c 100644 --- a/app/Containers/AppSection/Authentication/Tests/Unit/ResetPasswordActionTest.php +++ b/app/Containers/AppSection/Authentication/Tests/Unit/ResetPasswordActionTest.php @@ -4,11 +4,13 @@ use App\Containers\AppSection\Authentication\Actions\ResetPasswordAction; use App\Containers\AppSection\Authentication\Exceptions\InvalidResetPasswordTokenException; +use App\Containers\AppSection\Authentication\Notifications\PasswordReset; use App\Containers\AppSection\Authentication\Tasks\CreatePasswordResetTokenTask; use App\Containers\AppSection\Authentication\Tests\TestCase; use App\Containers\AppSection\Authentication\UI\API\Requests\ResetPasswordRequest; use App\Containers\AppSection\User\Models\User; use App\Ship\Exceptions\NotFoundException; +use Illuminate\Support\Facades\Notification; /** * Class ResetPasswordActionTest. @@ -20,6 +22,23 @@ class ResetPasswordActionTest extends TestCase { private User $user; + public function testResetPassword(): void + { + Notification::fake(); + $token = app(CreatePasswordResetTokenTask::class)->run($this->user); + $data = [ + 'email' => $this->user->email, + 'token' => $token, + 'password' => 'new pass', + 'password_confirmation' => 'new pass', + ]; + $request = new ResetPasswordRequest($data); + + app(ResetPasswordAction::class)->run($request); + + Notification::assertSentTo($this->user, PasswordReset::class); + } + public function testResetPasswordWithInvalidToken_ThrowsException(): void { $this->expectException(InvalidResetPasswordTokenException::class);