Sulu\Bundle\SecurityBundle\Entity\User::removeUserGroup PHP Method

removeUserGroup() public method

Remove userGroups.
public removeUserGroup ( UserGroup $userGroups )
$userGroups UserGroup
    public function removeUserGroup(UserGroup $userGroups)
    {
        $this->userGroups->removeElement($userGroups);
    }

Usage Example

 public function testNegativeVoteWithoutGroup()
 {
     foreach ($this->user->getUserGroups() as $userGroup) {
         $this->user->removeUserGroup($userGroup);
     }
     $access = $this->voter->vote($this->token->reveal(), new SecurityCondition('sulu.security.roles'), ['security']);
     $this->assertSame(VoterInterface::ACCESS_DENIED, $access);
 }