function it_encodes_password(EncoderFactoryInterface $encoderFactory, PasswordEncoderInterface $passwordEncoder, UserInterface $user) { $user->getPlainPassword()->willReturn('topSecretPlainPassword'); $user->getSalt()->willReturn('typicalSalt'); $encoderFactory->getEncoder($user)->willReturn($passwordEncoder); $passwordEncoder->encodePassword('topSecretPlainPassword', 'typicalSalt')->willReturn('topSecretEncodedPassword'); $this->encode($user)->shouldReturn('topSecretEncodedPassword'); }
public function it_does_nothing_if_plain_password_is_empty($encoderFactory, PasswordEncoderInterface $encoder, UserInterface $user) { $user->getPlainPassword()->willReturn(''); $user->getSalt()->willReturn('typicalSalt'); $encoderFactory->getEncoder($user)->shouldNotBeCalled(); $encoder->encodePassword('', 'typicalSalt')->shouldNotBeCalled(); $user->setPassword(Argument::any())->shouldNotBeCalled(); $user->eraseCredentials()->shouldNotBeCalled(); $this->updatePassword($user); }
/** * {@inheritdoc} * * @throws \LogicException when the algorithm is not supported */ public function encode(UserInterface $user) { return $this->encodePassword($user->getPlainPassword(), $user->getSalt()); }
function it_encodes_password(UserInterface $user) { $user->getPlainPassword()->willReturn('myPassword'); $user->getSalt()->willReturn('typicalSalt'); $this->encode($user)->shouldReturn('G1DuArwJiu+4Ctk9p2965gC3SXjGcom6gNhmV0OGUm79Kb9Anm5GWg=='); }