protected function addNewUser($username, $email, $password) { $user = new User(); $user->setUsername($username); $user->setEmail($email); $user->setPlainPassword($password); $this->em->persist($user); return $user; }
public function thereIsUser($username, $email, $password, $role = 'ROLE_USER', $enabled = true) { $user = new User(); $user->setUsername($username); $user->setEmail($email); $user->setEnabled($enabled); $user->setPlainPassword($password); if (null !== $role) { $user->addRole($role); } $this->getEntityManager()->persist($user); return $user; }