Example #1
0
 /**
  * @test
  */
 public function resultIsJsonSerializable()
 {
     $data = ['one', 2, '3'];
     $page = new Page(3, 4);
     $total = 322;
     $result = new Result($data, $page, $total);
     $stringified = (string) $result;
     $this->assertEquals(json_encode(['meta' => ['offset' => $page->getOffset(), 'limit' => $page->getLimit(), 'total' => $total], 'data' => $data]), $stringified);
 }
Example #2
0
 /**
  * @test
  */
 public function nonIntegerOffsetBecomesZero()
 {
     $page = new Page('somethin');
     $this->assertEquals(0, $page->getOffset());
     $this->assertInternalType('int', $page->getOffset());
 }
Example #3
0
 /**
  * Applies pagination offset/limit values to the QueryBuilder
  * @param QueryBuilder $qb
  * @param Page $page
  * @param Params $params
  */
 protected function applyListPagination(QueryBuilder $qb, Page $page, Params $params)
 {
     $qb->setFirstResult($page->getOffset())->setMaxResults($page->getLimit());
 }