/** @test */
 public function it_return_same_code_for_second_request()
 {
     $notifier = $this->mock('App\\Contracts\\Notifications\\UserNotifier');
     $notifier->shouldReceive('sendResetPasswordInfo')->twice();
     $userRepoMock = $this->app->make('App\\Repositories\\UserRepository');
     $actionLog = $this->app->make('App\\Contracts\\Log\\ActionsLog');
     $credentials = ['email' => $this->getUserForAuth()->email];
     $passwordBroker = new PasswordBroker($userRepoMock, $notifier, $actionLog);
     $passwordResetToken = $passwordBroker->sendResetInformation($credentials);
     $secondPasswordResetToken = $passwordBroker->sendResetInformation($credentials);
     $this->assertEquals($secondPasswordResetToken->getDecryptedCode(), $passwordResetToken->getDecryptedCode());
     $this->assertEquals($secondPasswordResetToken->id, $passwordResetToken->id);
 }
 public function postRequestCode(PasswordBroker $passwordBroker)
 {
     $validationResult = $this->validate(ResetPasswordCodeRequest::class);
     if ($validationResult->isValid()) {
         try {
             $passwordBroker->sendResetInformation($this->getValidatedData());
         } catch (EmailNotFoundException $e) {
             $validationResult->addError('email', '{reset_password.request_code.error.email.not_exists}');
         }
     }
     $view = $validationResult->isValid() ? 'reset_password.code_requested' : 'reset_password.request_code';
     return view($view, ['validationResult' => $validationResult, 'data' => $this->getValidatedData()]);
 }