Imbo\Auth\AccessControl\Adapter\ArrayAdapter::getGroups PHP Метод

getGroups() публичный Метод

public getGroups ( Imbo\Auth\AccessControl\GroupQuery $query = null, Groups $model )
$query Imbo\Auth\AccessControl\GroupQuery
$model Imbo\Model\Groups
    public function getGroups(GroupQuery $query = null, GroupsModel $model)
    {
        if ($query === null) {
            $query = new GroupQuery();
        }
        $model->setHits(count($this->groups));
        $offset = ($query->page() - 1) * $query->limit();
        return array_slice($this->groups, $offset, $query->limit(), true);
    }

Usage Example

Пример #1
0
 /**
  * @dataProvider getGroupsData
  * @covers Imbo\Auth\AccessControl\Adapter\ArrayAdapter::getGroups
  */
 public function testCanGetGroups(array $groups, array $result, $query = null)
 {
     $numGroups = count($groups);
     $model = $this->getMock('Imbo\\Model\\Groups');
     $model->expects($this->once())->method('setHits')->with($numGroups);
     $adapter = new ArrayAdapter([], $groups);
     $this->assertSame(array_values($result), array_values($adapter->getGroups($query, $model)));
 }