/**
  * {@inheritDoc}
  */
 public function handle(MassActionHandlerArgs $args)
 {
     $limitResult = $this->limiter->getLimitResult($args);
     $method = $this->requestStack->getMasterRequest()->getMethod();
     if ($method === 'POST') {
         $result = $this->getPostResponse($limitResult);
     } elseif ($method === 'DELETE') {
         $this->limiter->limitQuery($limitResult, $args);
         $result = $this->doDelete($args);
     } else {
         $result = $this->getNotSupportedResponse($method);
     }
     return $result;
 }
 /**
  * @dataProvider getLimitQueryDataProvider
  *
  * @param MassDeleteLimitResult $limitResult
  * @param bool                  $accessRestriction
  * @param bool                  $maxLimitRestriction
  *
  * @internal     param $MassDeleteLimitResult $
  */
 public function testLimitQuery(MassDeleteLimitResult $limitResult, $accessRestriction = false, $maxLimitRestriction = false)
 {
     /** @var QueryBuilder|\PHPUnit_Framework_MockObject_MockObject $queryBuilder */
     $queryBuilder = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     /** @var MassActionHandlerArgs|\PHPUnit_Framework_MockObject_MockObject $args */
     $args = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Extension\\MassAction\\MassActionHandlerArgs')->disableOriginalConstructor()->getMock();
     $args->expects($this->once())->method('getResults')->willReturn(new DeletionIterableResult($queryBuilder));
     if ($accessRestriction) {
         $this->helper->expects($this->once())->method('apply')->with($queryBuilder, 'DELETE');
     }
     if ($maxLimitRestriction) {
         $queryBuilder->expects($this->once())->method('setMaxResults')->with($limitResult->getMaxLimit());
     }
     $this->limiter->limitQuery($limitResult, $args);
 }