public function getHumanReadable($segmentString, $idSite)
 {
     if (empty($segmentString)) {
         return Piwik::translate('SegmentEditor_DefaultAllVisits');
     }
     try {
         $segment = new SegmentExpression(urldecode($segmentString));
         $expressions = $segment->parseSubExpressions();
     } catch (Exception $e) {
         $segment = new SegmentExpression($segmentString);
         $expressions = $segment->parseSubExpressions();
     }
     $readable = '';
     foreach ($expressions as $expression) {
         $operator = $expression[SegmentExpression::INDEX_BOOL_OPERATOR];
         $operand = $expression[SegmentExpression::INDEX_OPERAND];
         $name = $operand[SegmentExpression::INDEX_OPERAND_NAME];
         $segment = $this->segmentList->findSegment($name, $idSite);
         if (empty($segment)) {
             throw new Exception(sprintf("The segment '%s' does not exist.", $name));
         }
         $readable .= $segment['name'] . ' ';
         $readable .= $this->getTranslationForComparison($operand, $segment['type']) . ' ';
         $readable .= $this->getFormattedValue($operand);
         $readable .= $this->getTranslationForBoolOperator($operator) . ' ';
     }
     $readable = trim($readable);
     return $readable;
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage checkUserHasViewAccess
  */
 public function test_findSegment_ShouldThrowException_IfNotEnoughPermission()
 {
     FakeAccess::clearAccess($superUser = false, array(1));
     $segment = $this->list->findSegment('pageUrl', 999);
     $this->assertNull($segment);
 }