/**
  * Process one expression an enqueue it using the ExprBuilder instance.
  *
  * @param  ExprBuilder $builder
  * @param  string      $field
  * @param  string      $expression
  * @param  string      $value
  *
  * @return ExprBuilder
  *
  * @throws ParserException
  */
 public function process(ExprBuilder $builder, $field, $expression, $value)
 {
     if (!Expr::isValidExpression($expression)) {
         throw new ParserException(sprintf('The expression "%s" is not allowed or not exists.', $expression));
     }
     switch ($expression) {
         case 'between':
             set_error_handler(function () use($value) {
                 throw new ParserException(sprintf('The value of "between" expression "%s" is not valid.', $value));
             });
             list($from, $to) = explode('-', $value);
             restore_error_handler();
             return $builder->between($field, $from, $to);
         case 'paginate':
             set_error_handler(function () use($value) {
                 throw new ParserException(sprintf('The value of "paginate" expression "%s" is not valid.', $value));
             });
             list($currentPageNumber, $maxResultsPerPage) = explode('-', $value);
             restore_error_handler();
             return $builder->paginate($currentPageNumber, $maxResultsPerPage);
         case 'or':
             return $builder->orx($value);
         default:
             return $builder->{$expression}($field, $value);
     }
 }
 public function testProcessWithEqExpression()
 {
     $processor = $this->getMockBuilder('\\Cekurte\\Resource\\Query\\Language\\Processor\\DoctrineOrmProcessor')->setConstructorArgs([$this->getDoctrineOrmQueryBuilder()])->setMethods(['processComparisonExpr'])->getMock();
     $processor->expects($this->once())->method('processComparisonExpr')->will($this->returnValue(null));
     $builder = new ExprBuilder();
     $processor->process($builder->eq('field', 'value'));
 }