/** * @Acl(action="view") */ public function indexAction() { $this->_helper->layout->setLayout('admin'); $this->view->form = $this->getForm()->setMethod('get')->setAction(''); $criteria = array(); $orderBy = array('id' => 'desc'); $limit = 10; $offset = 0; if ($this->view->form->isValid($this->getRequest()->getParams())) { $resourceType = $this->getRequest()->getParam('resource_type', ''); $actionType = $this->getRequest()->getParam('action_type', ''); $resourceTypes = $this->auditService->getResourceTypes(); $actionTypes = $this->auditService->getActionTypes(); if ($resourceType != '') { $criteria['resource_type'] = $resourceTypes[$resourceType]; } if ($actionType != '') { $criteria['action'] = $actionTypes[$actionType]; } $offset = $this->getRequest()->getParam('offset', 0); } $count = $this->auditService->countBy($criteria); $this->view->events = $this->auditService->findBy($criteria, $orderBy, $limit, $offset); $this->view->pager = new SimplePager($count, $limit, 'offset', '?'); }
public function testFindBy() { $result = array(1, 2, 4); $criteria = array('resource' => 'article'); $orderBy = array('created'); $limit = 5; $offset = 1; $this->repository->expects($this->once())->method('findBy')->with($this->equalTo($criteria), $this->equalTo($orderBy), $this->equalTo($limit), $this->equalTo($offset))->will($this->returnValue($result)); $this->em->expects($this->once())->method('getRepository')->with($this->equalTo('Newscoop\\Entity\\AuditEvent'))->will($this->returnValue($this->repository)); $this->assertEquals($result, $this->service->findBy($criteria, $orderBy, $limit, $offset)); }