/** * @test */ public function testGetCriteria() { $processor = new BranchFilterCriteriaProcessor(); $processor->setCommand($this->branchFilterCommand); $expectedCriteria = array(array('name', 'like', 'default'), array('defaultAssignee', 'eq', 1), array('description', 'like', 'Default description'), array('key', 'like', 'DB')); $criteria = $processor->getCriteria(); $this->assertNotEmpty($criteria); $this->assertCount(4, $criteria); for ($i = 0; $i < count($expectedCriteria); $i++) { $this->assertEquals($expectedCriteria[$i], $criteria[$i]); } }
/** * Retrieves list of all Branches. Filters branches with parameters provided within GET request * Time filtering parameters as well as paging/sorting configuration parameters can be found in \Diamante\DeskBundle\Api\Command\CommonFilterCommand class. * Time filtering values should be converted to UTC * * @ApiDoc( * description="Returns all branches", * uri="/branches.{_format}", * method="GET", * resource=true, * statusCodes={ * 200="Returned when successful", * 403="Returned when the user is not authorized to list branches" * } * ) * @param Command\Filter\FilterBranchesCommand $command|null * @return \Diamante\DeskBundle\Model\Branch\Branch[] */ public function listAllBranches(Command\Filter\FilterBranchesCommand $command = null) { $processor = new BranchFilterCriteriaProcessor(); $processor->setCommand($command); $criteria = $processor->getCriteria(); $pagingProperties = $processor->getPagingProperties(); $repository = $this->getBranchRepository(); $branches = $repository->filter($criteria, $pagingProperties); try { $pagingInfo = $this->apiPagingService->getPagingInfo($repository, $pagingProperties, $criteria); $this->populatePagingHeaders($this->apiPagingService, $pagingInfo); } catch (\Exception $e) { } return $branches; }