public function testRole()
 {
     $name = 'test role#$%';
     $role = new AccountUserRole();
     $account = new Account();
     $organization = new Organization();
     $this->assertEmpty($role->getId());
     $this->assertEmpty($role->getLabel());
     $this->assertEmpty($role->getRole());
     $this->assertEmpty($role->getOrganization());
     $this->assertEmpty($role->getAccount());
     $role->setAccount($account);
     $role->setOrganization($organization);
     $this->assertEquals($organization, $role->getOrganization());
     $this->assertEquals($account, $role->getAccount());
     $role->setLabel($name);
     $this->assertEquals($name, $role->getLabel());
     $this->assertEquals(AccountUserRole::PREFIX_ROLE, $role->getPrefix());
     $role->setRole($name);
     $this->assertStringStartsWith(AccountUserRole::PREFIX_ROLE . 'TEST_ROLE_', $role->getRole());
     $this->assertEquals($name, (string) $role);
 }
 /**
  * @param string $type
  * @return int
  */
 protected function getPermissionForAccountRole($type)
 {
     /* @var $user AccountUser */
     $user = $this->getLoggedUser();
     /** @var Account $account */
     $account = $this->object->getAccount();
     if (!$user instanceof AccountUser) {
         return self::ACCESS_ABSTAIN;
     }
     $isGranted = false;
     switch ($type) {
         case self::VIEW:
             $isGranted = $this->isGrantedViewAccountUserRole();
             break;
         case self::UPDATE:
             $isGranted = $this->isGrantedUpdateAccountUserRole();
             break;
     }
     if ($isGranted && (!$account || $account->getId() === $user->getAccount()->getId())) {
         return self::ACCESS_GRANTED;
     }
     return self::ACCESS_ABSTAIN;
 }