Exemplo n.º 1
0
 /**
  * @dataProvider getBogusFilters
  * @group Core
  */
 public function testBogusFiltersExpectExceptionThrown($bogus)
 {
     try {
         $segment = new SegmentExpression($bogus);
         $segment->parseSubExpressions();
         $segment->getSql();
     } catch (Exception $e) {
         return;
     }
     $this->fail('Expected exception not raised for:' . var_export($segment->getSql(), true));
 }
Exemplo n.º 2
0
 /**
  * @param $string
  * @param $idSites
  * @throws Exception
  */
 protected function initializeSegment($string, $idSites)
 {
     // As a preventive measure, we restrict the filter size to a safe limit
     $string = substr($string, 0, self::SEGMENT_TRUNCATE_LIMIT);
     $this->string = $string;
     $this->idSites = $idSites;
     $segment = new SegmentExpression($string);
     $this->segment = $segment;
     // parse segments
     $expressions = $segment->parseSubExpressions();
     // convert segments name to sql segment
     // check that user is allowed to view this segment
     // and apply a filter to the value to match if necessary (to map DB fields format)
     $cleanedExpressions = array();
     foreach ($expressions as $expression) {
         $operand = $expression[SegmentExpression::INDEX_OPERAND];
         $cleanedExpression = $this->getCleanedExpression($operand);
         $expression[SegmentExpression::INDEX_OPERAND] = $cleanedExpression;
         $cleanedExpressions[] = $expression;
     }
     $segment->setSubExpressionsAfterCleanup($cleanedExpressions);
 }