예제 #1
0
 public function testCanGetListOfGroupsByRole()
 {
     $roleLevel = RoleLevel::GROUP_ADMIN;
     $groupItemRow = new GroupItemRow();
     $groupItemRow->With(1, 'g1')->With(2, 'g2');
     $rows = $groupItemRow->Rows();
     $this->db->SetRow(0, $rows);
     $getGroupsCommand = new GetAllGroupsByRoleCommand($roleLevel);
     $groups = $this->repository->GetGroupsByRole($roleLevel);
     $this->assertEquals(GroupItemView::Create($rows[0]), $groups[0]);
     $this->assertEquals(GroupItemView::Create($rows[1]), $groups[1]);
     $this->assertTrue($this->db->ContainsCommand($getGroupsCommand), "missing select group command");
 }
예제 #2
0
 /**
  * @param $roleLevel int|RoleLevel
  * @return GroupItemView[]|array
  */
 public function GetGroupsByRole($roleLevel)
 {
     $reader = ServiceLocator::GetDatabase()->Query(new GetAllGroupsByRoleCommand($roleLevel));
     $groups = array();
     while ($row = $reader->GetRow()) {
         $groups[] = GroupItemView::Create($row);
     }
     $reader->Free();
     return $groups;
 }