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()); }