/**
  * Parse a query string given in SMW's query language to create an Query.
  * Parameters are given as key-value-pairs in the given array. The parameter
  * $context defines in what context the query is used, which affects certaim
  * general settings.
  *
  * @since 2.5
  *
  * @param string $queryString
  *
  * @return Query
  */
 public function createFromString($queryString)
 {
     $context = $this->getFromConfigurationWith('context', self::INLINE_QUERY);
     $queryParser = $this->queryFactory->newQueryParser($context == self::CONCEPT_DESC ? $this->conceptFeatures : $this->queryFeatures);
     $contextPage = $this->getFromConfigurationWith('contextPage', null);
     $queryMode = $this->getFromConfigurationWith('queryMode', self::MODE_INSTANCES);
     $queryParser->setContextPage($contextPage);
     $queryParser->setDefaultNamespaces($this->defaultNamespaces);
     $query = $this->queryFactory->newQuery($queryParser->getQueryDescription($queryString), $context);
     $query->setQueryString($queryString);
     $query->setContextPage($contextPage);
     $query->setQuerymode($queryMode);
     $query->setExtraPrintouts($this->getFromConfigurationWith('extraPrintouts', array()));
     $query->setMainLabel($this->getFromConfigurationWith('mainLabel', ''));
     $query->setQuerySource($this->getFromConfigurationWith('querySource', null));
     // keep parsing or other errors for later output
     $query->addErrors($queryParser->getErrors());
     // set sortkeys, limit, and offset
     $query->setOffset(max(0, trim($this->getFromConfigurationWith('offset', 0)) + 0));
     $query->setLimit(max(0, trim($this->getFromConfigurationWith('limit', $this->defaultLimit)) + 0), $queryMode != self::MODE_COUNT);
     $sortKeys = $this->getSortKeys($this->getFromConfigurationWith('sort', array()), $this->getFromConfigurationWith('order', array()), $this->getFromConfigurationWith('defaultSort', 'ASC'));
     $query->addErrors($sortKeys['errors']);
     $query->setSortKeys($sortKeys['keys']);
     return $query;
 }
 public function testCanConstructQueryParser()
 {
     $instance = new QueryFactory();
     $this->assertInstanceOf('\\SMWQueryParser', $instance->newQueryParser());
 }