/**
  * @since 2.2
  *
  * @return QueryEngine
  */
 public function newMasterQueryEngine()
 {
     $engineOptions = new EngineOptions();
     $propertyHierarchyExaminer = new PropertyHierarchyExaminer($this->store, ApplicationFactory::getInstance()->newCacheFactory()->newFixedInMemoryCache(500));
     $circularReferenceGuard = new CircularReferenceGuard('sparql-query');
     $circularReferenceGuard->setMaxRecursionDepth(2);
     $compoundConditionBuilder = new CompoundConditionBuilder($engineOptions);
     $compoundConditionBuilder->setCircularReferenceGuard($circularReferenceGuard);
     $compoundConditionBuilder->setPropertyHierarchyExaminer($propertyHierarchyExaminer);
     $queryEngine = new QueryEngine($this->store->getConnection('sparql'), $compoundConditionBuilder, new QueryResultFactory($this->store), $engineOptions);
     return $queryEngine;
 }
 public function testHierarchyPattern()
 {
     $property = new DIProperty('Foo');
     $propertyHierarchyExaminer = $this->getMockBuilder('\\SMW\\PropertyHierarchyExaminer')->disableOriginalConstructor()->getMock();
     $propertyHierarchyExaminer->expects($this->once())->method('hasSubpropertyFor')->with($this->equalTo($property))->will($this->returnValue(true));
     $resultVariable = 'result';
     $compoundConditionBuilder = new CompoundConditionBuilder();
     $compoundConditionBuilder->setPropertyHierarchyExaminer($propertyHierarchyExaminer);
     $compoundConditionBuilder->setResultVariable($resultVariable);
     $compoundConditionBuilder->setJoinVariable($resultVariable);
     $instance = new SomePropertyInterpreter($compoundConditionBuilder);
     $description = new SomeProperty($property, new ThingDescription());
     $condition = $instance->interpretDescription($description);
     $expected = UtilityFactory::getInstance()->newStringBuilder()->addString('?result ?sp2 ?v1 .')->addNewLine()->addString('{ ')->addNewLine()->addString('?sp2 rdfs:subPropertyOf* property:Foo .')->addNewLine()->addString('}')->addNewLine()->getString();
     $this->assertEquals($expected, $compoundConditionBuilder->convertConditionToString($condition));
 }
 public function testHierarchyPattern()
 {
     $category = new DIWikiPage('Foo', NS_CATEGORY);
     $categoryName = \SMWTurtleSerializer::getTurtleNameForExpElement(\SMWExporter::getInstance()->getResourceElementForWikiPage($category));
     $propertyHierarchyExaminer = $this->getMockBuilder('\\SMW\\PropertyHierarchyExaminer')->disableOriginalConstructor()->getMock();
     $propertyHierarchyExaminer->expects($this->once())->method('hasSubcategoryFor')->with($this->equalTo($category))->will($this->returnValue(true));
     $resultVariable = 'result';
     $compoundConditionBuilder = new CompoundConditionBuilder();
     $compoundConditionBuilder->setPropertyHierarchyExaminer($propertyHierarchyExaminer);
     $compoundConditionBuilder->setResultVariable($resultVariable);
     $compoundConditionBuilder->setJoinVariable($resultVariable);
     $instance = new ClassDescriptionInterpreter($compoundConditionBuilder);
     $condition = $instance->interpretDescription(new ClassDescription($category));
     $expected = UtilityFactory::getInstance()->newStringBuilder()->addString('{')->addNewLine()->addString("?sc1 rdfs:subClassOf* {$categoryName} .")->addNewLine()->addString('?result rdf:type ?sc1 . }')->addNewLine()->getString();
     $this->assertEquals($expected, $compoundConditionBuilder->convertConditionToString($condition));
 }