function let(Generator $generator, HasInitialPassword $user, LifecycleEventArgs $event) { $generator->generate()->willReturn('password'); $event->getObject()->willReturn($user); $user->getPlainPassword()->willReturn(null); $this->beConstructedWith($generator); }
/** * @param LifecycleEventArgs $event * * @return false|void False if nothing was done */ public function prePersist(LifecycleEventArgs $event) { $object = $event->getObject(); if (false === $object instanceof HasInitialPassword) { return false; } if (null !== $object->getPlainPassword()) { return false; } $plainPassword = $this->generator->generate(); $object->setPlainPassword($plainPassword); }