public function testGetAssociationsByRole()
 {
     $assoc = AccessControlAssociation::getNewInstance($this->userGroup, $this->role);
     $assoc->save();
     $associations = AccessControlAssociation::getRecordSetByRole($this->role, new ARSelectFilter());
     $this->assertEqual($associations->getTotalRecordCount(), 1);
     $this->assertSame($associations->get(0)->userGroup->get(), $this->userGroup);
 }
Ejemplo n.º 2
0
 public function testGetRolesRecordSet()
 {
     $role = Role::getNewInstance('__testrole__');
     $role->save();
     $userGroup = UserGroup::getNewInstance('Any random group name');
     $userGroup->save();
     $assoc = AccessControlAssociation::getNewInstance($userGroup, $role);
     $assoc->save();
     $rolesRecordSet = $userGroup->getRolesRecordSet();
     $this->assertEqual($rolesRecordSet->getTotalRecordCount(), 1);
     $this->assertSame($rolesRecordSet->get(0), $role);
 }
Ejemplo n.º 3
0
 public function getRolesRecordSet(ARSelectFilter $filter = null, $loadReferencedRecords = false)
 {
     if (!$filter) {
         $filter = new ARSelectFilter();
     }
     $rolesRecordSet = new ARSet();
     foreach (AccessControlAssociation::getRecordSetByUserGroup($this, $filter) as $association) {
         $rolesRecordSet->add($association->role->get());
     }
     return $rolesRecordSet;
 }