Esempio n. 1
0
 private function loadUsers(ObjectManager $manager)
 {
     $passwordEncoder = $this->container->get('security.password_encoder');
     $johnUser = new User();
     $johnUser->setUsername('john_user');
     $johnUser->setEmail('*****@*****.**');
     $encodedPassword = $passwordEncoder->encodePassword($johnUser, 'kitten');
     $johnUser->setPassword($encodedPassword);
     $manager->persist($johnUser);
     $dimaAdmin = new User();
     $dimaAdmin->setUsername('dima');
     $dimaAdmin->setEmail('*****@*****.**');
     $dimaAdmin->setRoles(array('ROLE_ADMIN'));
     $encodedPassword = $passwordEncoder->encodePassword($dimaAdmin, '2045');
     $dimaAdmin->setPassword($encodedPassword);
     $manager->persist($dimaAdmin);
     $manager->flush();
 }
 public function testSubmit()
 {
     $user = new User();
     $user->setFullName('NameTest');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('test');
     $user->setUsername('bar');
     $type = new RegistrationType();
     $form = $this->formFactory->create($type);
     $formData = array('fullName' => 'NameTest', 'username' => 'bar', 'email' => '*****@*****.**', 'plainPassword' => array('first' => 'test', 'second' => 'test'));
     $form->submit($formData);
     $data = $form->getData();
     $this->assertTrue($form->isSynchronized());
     $this->assertFalse($form->isValid());
     $this->assertTrue($data instanceof $user);
     $this->assertEquals($data->getUsername(), $user->getUsername());
     $this->assertEquals($data->getEmail(), $user->getEmail());
     $this->assertEquals($data->getPlainPassword(), $user->getPlainPassword());
 }