Inheritance: extends FOS\UserBundle\Model\User, implements Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface, implements Scheb\TwoFactorBundle\Model\TrustedComputerInterface
 public function testWithoutLanguage()
 {
     $session = new Session(new MockArraySessionStorage());
     $listener = new UserLocaleListener($session);
     $user = new User();
     $user->setEnabled(true);
     $config = new Config($user);
     $user->setConfig($config);
     $userToken = new UsernamePasswordToken($user, '', 'test');
     $request = Request::create('/');
     $event = new InteractiveLoginEvent($request, $userToken);
     $listener->onInteractiveLogin($event);
     $this->assertEquals('', $session->get('_locale'));
 }
 public function testWithValidUser()
 {
     $user = new User();
     $user->setEnabled(true);
     $event = new FilterUserResponseEvent($user, $this->request, $this->response);
     $config = new Config($user);
     $config->setTheme('baggy');
     $config->setItemsPerPage(20);
     $config->setRssLimit(50);
     $config->setLanguage('fr');
     $config->setReadingSpeed(1);
     $this->em->expects($this->once())->method('persist')->will($this->returnValue($config));
     $this->em->expects($this->once())->method('flush');
     $this->dispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, $event);
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setName('Big boss');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setUsername('admin');
     $userAdmin->setPlainPassword('mypassword');
     $userAdmin->setEnabled(true);
     $userAdmin->addRole('ROLE_SUPER_ADMIN');
     $manager->persist($userAdmin);
     $this->addReference('admin-user', $userAdmin);
     $bobUser = new User();
     $bobUser->setName('Bobby');
     $bobUser->setEmail('*****@*****.**');
     $bobUser->setUsername('bob');
     $bobUser->setPlainPassword('mypassword');
     $bobUser->setEnabled(true);
     $manager->persist($bobUser);
     $this->addReference('bob-user', $bobUser);
     $emptyUser = new User();
     $emptyUser->setName('Empty');
     $emptyUser->setEmail('*****@*****.**');
     $emptyUser->setUsername('empty');
     $emptyUser->setPlainPassword('mypassword');
     $emptyUser->setEnabled(true);
     $manager->persist($emptyUser);
     $this->addReference('empty-user', $emptyUser);
     $manager->flush();
 }
Exemple #4
0
 /**
  * Global method to retrieve entries depending on the given type
  * It returns the response to be send.
  *
  * @param string $type Entries type: unread, starred or archive
  * @param User   $user
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 private function showEntries($type, User $user)
 {
     $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
     switch ($type) {
         case 'starred':
             $qb = $repository->getBuilderForStarredByUser($user->getId());
             break;
         case 'archive':
             $qb = $repository->getBuilderForArchiveByUser($user->getId());
             break;
         case 'unread':
             $qb = $repository->getBuilderForUnreadByUser($user->getId());
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
     }
     $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
     $entries = new Pagerfanta($pagerAdapter);
     $perPage = $user->getConfig()->getRssLimit() ?: $this->getParameter('wallabag_core.rss_limit');
     $entries->setMaxPerPage($perPage);
     return $this->render('@WallabagCore/themes/common/Entry/entries.xml.twig', ['type' => $type, 'entries' => $entries]);
 }
 public function testSendEmail()
 {
     $user = new User();
     $user->setTwoFactorAuthentication(true);
     $user->setEmailAuthCode(666666);
     $user->setEmail('*****@*****.**');
     $user->setName('Bob');
     $authCodeMailer = new AuthCodeMailer($this->mailer, $this->twig, '*****@*****.**', 'wallabag test', $this->config);
     $authCodeMailer->sendAuthCode($user);
     $this->assertCount(1, $this->spool);
     $msg = $this->spool->getMessages()[0];
     $this->assertArrayHasKey('*****@*****.**', $msg->getTo());
     $this->assertEquals(['*****@*****.**' => 'wallabag test'], $msg->getFrom());
     $this->assertEquals('subject', $msg->getSubject());
     $this->assertContains('text body http://0.0.0.0/support', $msg->toString());
     $this->assertContains('html body 666666', $msg->toString());
 }
 /**
  * Creates a form to delete a User entity.
  *
  * @param User $user The User entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(User $user)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('user_delete', array('id' => $user->getId())))->setMethod('DELETE')->getForm();
 }
 /**
  * Retrieves the tagging rules for a given user.
  *
  * @param User $user
  *
  * @return array<TaggingRule>
  */
 private function getRulesForUser(User $user)
 {
     return $user->getConfig()->getTaggingRules();
 }
 private function getUser(array $taggingRules = [])
 {
     $user = new User();
     $config = new Config($user);
     $user->setConfig($config);
     foreach ($taggingRules as $rule) {
         $config->addTaggingRule($rule);
     }
     return $user;
 }