Skip to content

Commit

Permalink
Add ResetPasswordActionTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Dec 12, 2021
1 parent e228180 commit 91eddb5
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down

0 comments on commit 91eddb5

Please sign in to comment.