function let(Generator $generator, HasSalt $user, LifecycleEventArgs $event)
 {
     $generator->generate()->willReturn('salt');
     $event->getObject()->willReturn($user);
     $user->getSalt()->willReturn(null);
     $this->beConstructedWith($generator);
 }
Пример #2
0
 /**
  * @param LifecycleEventArgs $event
  *
  * @return false|void False if nothing was done
  */
 public function prePersist(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     if (false === $object instanceof HasSalt) {
         return false;
     }
     if (null !== $object->getSalt()) {
         return false;
     }
     $salt = $this->generator->generate();
     $object->setSalt($salt);
 }