public function testSubmit()
 {
     $user = new TestUser();
     $user->setPassword('foo');
     $form = $this->factory->create(LegacyFormHelper::getType('FOS\\UserBundle\\Form\\Type\\ChangePasswordFormType'), $user);
     $formData = array('current_password' => 'foo', 'plainPassword' => array('first' => 'bar', 'second' => 'bar'));
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($user, $form->getData());
     $this->assertEquals('bar', $user->getPlainPassword());
 }
Exemplo n.º 2
0
 public function testCreateUserAce()
 {
     $aclProviderMock = $this->getMock('Symfony\\Component\\Security\\Acl\\Model\\MutableAclProviderInterface');
     $user = new TestUser();
     $user->setId(42);
     $user->setUsername('test_user');
     $objectIdentity = new ObjectIdentity('exampleidentifier', 'userperhaps');
     $permissionGrantingStrategy = new PermissionGrantingStrategy();
     $acl = new Acl(1, $objectIdentity, $permissionGrantingStrategy, array(), true);
     $aclProviderMock->expects($this->once())->method('createAcl')->will($this->returnValue($acl))->with($this->isInstanceOf('Symfony\\Component\\Security\\Acl\\Model\\ObjectIdentityInterface'));
     $aclProviderMock->expects($this->once())->method('updateAcl')->with($this->isInstanceOf('Symfony\\Component\\Security\\Acl\\Domain\\Acl'));
     $aceManager = new AceManager($aclProviderMock);
     $aceManager->createUserAce($user);
 }
 public function testChangePasswordWithValidUsername()
 {
     $userManagerMock = $this->createMock('FOS\\UserBundle\\Model\\UserManagerInterface');
     $user = new TestUser();
     $username = '******';
     $password = '******';
     $oldpassword = '******';
     $user->setUsername($username);
     $user->setPlainPassword($oldpassword);
     $userManagerMock->expects($this->once())->method('findUserByUsername')->will($this->returnValue($user))->with($this->equalTo($username));
     $userManagerMock->expects($this->once())->method('updateUser')->will($this->returnValue($user))->with($this->isInstanceOf('FOS\\UserBundle\\Tests\\TestUser'));
     $manipulator = new UserManipulator($userManagerMock);
     $manipulator->changePassword($username, $password);
     $this->assertEquals($username, $user->getUsername());
     $this->assertEquals($password, $user->getPlainPassword());
 }