Exemplo n.º 1
0
 public function testGetWithSorting()
 {
     $this->groupMetadata->setSorting(1);
     $group = $this->getGroupMock(3);
     $groups = array_fill(0, 3, $group);
     $this->groupManager->expects($this->once())->method('search')->with('')->will($this->returnValue($groups));
     list($adminGroups, $ordinaryGroups) = $this->groupMetadata->get();
     $this->assertSame(1, count($adminGroups));
     $this->assertSame(2, count($ordinaryGroups));
     $this->assertSame('g3', $ordinaryGroups[0]['name']);
     $this->assertSame(5, $ordinaryGroups[0]['usercount']);
 }
 /**
  * @NoAdminRequired
  *
  * @param string $pattern
  * @param bool $filterGroups
  * @param int $sortGroups
  * @return DataResponse
  */
 public function index($pattern = '', $filterGroups = false, $sortGroups = MetaData::SORT_USERCOUNT)
 {
     $groupPattern = $filterGroups ? $pattern : '';
     $groupsInfo = new MetaData($this->userSession->getUser()->getUID(), $this->isAdmin, $this->groupManager);
     $groupsInfo->setSorting($sortGroups);
     list($adminGroups, $groups) = $groupsInfo->get($groupPattern, $pattern);
     return new DataResponse(array('data' => array('adminGroups' => $adminGroups, 'groups' => $groups)));
 }