/**
  * Resalt a user's authentication table salt
  *
  * @param AuthenticationRecordInterface $auth
  *
  * @return AuthenticationRecordInterface
  */
 private function resetAuthenticationKey(AuthenticationRecordInterface $auth) : AuthenticationRecordInterface
 {
     $key = KeyFactory::generateEncryptionKey();
     $auth->setSessionKey($key->getRawKeyMaterial());
     $this->authenticationProvider->update($auth);
     return $auth;
 }
 public function let(AuthenticationMapper $authenticationMapper, UserMapper $userMapper, User $user)
 {
     $hash = password_hash('abc', PASSWORD_DEFAULT);
     $key = KeyFactory::generateEncryptionKey();
     $authenticationData = new Authentication(1, 'userA', $hash, $key->getRawKeyMaterial());
     $this->authenticationData = $authenticationData;
     $orphanAuthData = new Authentication(2, 'orphan', $hash, $key->getRawKeyMaterial());
     $authenticationMapper->findByUsername(Argument::any())->willReturn(null);
     $authenticationMapper->findByUsername('userA')->willReturn($authenticationData);
     $authenticationMapper->findByUsername('orphan')->willReturn($orphanAuthData);
     $authenticationMapper->findByUserId(Argument::any())->willReturn(null);
     $authenticationMapper->findByUserId(1)->willReturn($authenticationData);
     $authenticationMapper->update($authenticationData)->willReturn(true);
     $user->getId()->willReturn(1);
     $userMapper->findByEmail(Argument::any())->willReturn(null);
     $userMapper->findByEmail('*****@*****.**')->willReturn($user);
     $userMapper->getUser(Argument::any())->willReturn(null);
     $userMapper->getUser(1)->willReturn($user);
     $this->systemEncryptionKey = KeyFactory::generateEncryptionKey();
     $this->beConstructedWith($authenticationMapper, $userMapper, $this->systemEncryptionKey->getRawKeyMaterial(), false, false);
 }