/** * @test */ public function testGetPagingInfo() { $this->entityRepository->expects($this->once())->method('count')->with($this->equalTo(array(array('status', 'eq', 'new'))))->will($this->returnValue(150)); $this->pagingProperties->expects($this->once())->method('getLimit')->will($this->returnValue(25)); $this->pagingProperties->expects($this->once())->method('getPage')->will($this->returnValue(3)); $pagingInfo = $this->apiPagingServiceImpl->getPagingInfo($this->entityRepository, $this->pagingProperties, array(array('status', 'eq', 'new'))); $this->assertInstanceOf('Diamante\\DeskBundle\\Model\\Shared\\Filter\\PagingInfo', $pagingInfo); $this->assertEquals(150, $pagingInfo->getTotalRecords()); $this->assertEquals(6, $pagingInfo->getLastPage()); $this->assertEquals(1, $pagingInfo->getFirstPage()); $this->assertEquals(4, $pagingInfo->getNextPage()); $this->assertEquals(2, $pagingInfo->getPreviousPage()); $this->assertInstanceOf('Diamante\\DeskBundle\\Model\\Shared\\Filter\\PagingProperties', $pagingInfo->getPagingConfig()); }
/** * @param FilterableRepository $repository * @param PagingProperties $pagingConfig * @param array $criteria * @return PagingInfo */ public function getPagingInfo(FilterableRepository $repository, PagingProperties $pagingConfig, array $criteria) { $totalRecords = $repository->count($criteria); return new PagingInfo($totalRecords, $pagingConfig); }