public function testCanConstructQueryEngine()
 {
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $instance = new QueryEngineFactory($store);
     $this->assertInstanceOf('\\SMW\\SQLStore\\QueryEngine\\QueryEngine', $instance->newQueryEngine());
 }
 /**
  * @dataProvider descriptionProvider
  */
 public function testInterpretDescription($description, $expected)
 {
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $queryEngineFactory = new QueryEngineFactory($store);
     $instance = new DisjunctionConjunctionInterpreter($queryEngineFactory->newQuerySegmentListBuilder());
     $this->assertTrue($instance->canInterpretDescription($description));
     $this->querySegmentValidator->assertThatContainerHasProperties($expected, $instance->interpretDescription($description));
 }
 public function testInterpretDescription()
 {
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $description = $this->getMockBuilder('\\SMW\\Query\\Language\\ThingDescription')->disableOriginalConstructor()->getMockForAbstractClass();
     $expected = new \stdClass();
     $expected->type = 0;
     $expected->queryNumber = 0;
     $queryEngineFactory = new QueryEngineFactory($store);
     $instance = new ThingDescriptionInterpreter($queryEngineFactory->newQuerySegmentListBuilder());
     $this->assertTrue($instance->canInterpretDescription($description));
     $this->querySegmentValidator->assertThatContainerHasProperties($expected, $instance->interpretDescription($description));
 }
 /**
  * @dataProvider descriptionProvider
  */
 public function testCompileDescription($description, $pageId, $expected)
 {
     $objectIds = $this->getMockBuilder('\\stdClass')->setMethods(array('getSMWPageID'))->getMock();
     $objectIds->expects($this->any())->method('getSMWPageID')->will($this->returnValue($pageId));
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $store->expects($this->any())->method('getObjectIds')->will($this->returnValue($objectIds));
     $queryEngineFactory = new QueryEngineFactory($store);
     $instance = new ClassDescriptionInterpreter($queryEngineFactory->newQuerySegmentListBuilder());
     $this->assertTrue($instance->canInterpretDescription($description));
     $this->querySegmentValidator->assertThatContainerHasProperties($expected, $instance->interpretDescription($description));
 }
 public function testInterpretDescription()
 {
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $queryEngineFactory = new QueryEngineFactory($store);
     $description = $this->descriptionFactory->newNamespaceDescription(NS_HELP);
     $expected = new \stdClass();
     $expected->type = 1;
     $expected->where = "t0.smw_namespace=";
     $instance = new NamespaceDescriptionInterpreter($queryEngineFactory->newQuerySegmentListBuilder());
     $this->assertTrue($instance->canInterpretDescription($description));
     $this->querySegmentValidator->assertThatContainerHasProperties($expected, $instance->interpretDescription($description));
 }
 /**
  * @since 2.2
  *
  * @return ConceptCache
  */
 public function newMasterConceptCache()
 {
     $conceptQueryResolver = new ConceptQueryResolver($this->queryEngineFactory->newQueryEngine());
     $conceptQueryResolver->setConceptFeatures($GLOBALS['smwgQConceptFeatures']);
     $conceptCache = new ConceptCache($this->store, $conceptQueryResolver);
     $conceptCache->setUpperLimit($GLOBALS['smwgQMaxLimit']);
     return $conceptCache;
 }
 /**
  * @dataProvider descriptionProvider
  */
 public function testinterpretDescription($description, $isFixedPropertyTable, $indexField, $sortKeys, $expected)
 {
     $dataItemHandler = $this->getMockBuilder('\\SMW\\SQLStore\\EntityStore\\DataItemHandler')->disableOriginalConstructor()->getMockForAbstractClass();
     $dataItemHandler->expects($this->any())->method('getIndexField')->will($this->returnValue($indexField));
     $dataItemHandler->expects($this->any())->method('getTableFields')->will($this->returnValue(array('one', 'two')));
     $dataItemHandler->expects($this->any())->method('getWhereConds')->will($this->returnValue(array($indexField => 'fixedFooWhereCond')));
     $objectIds = $this->getMockBuilder('\\stdClass')->setMethods(array('getSMWPropertyID', 'getSMWPageID'))->getMock();
     $objectIds->expects($this->any())->method('getSMWPropertyID')->will($this->returnValue(42));
     $objectIds->expects($this->any())->method('getSMWPageID')->will($this->returnValue(91));
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $connection->expects($this->any())->method('addQuotes')->will($this->returnArgument(0));
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $proptable = $this->getMockBuilder('\\SMWSQLStore3Table')->disableOriginalConstructor()->getMock();
     $proptable->expects($this->any())->method('usesIdSubject')->will($this->returnValue(true));
     $proptable->expects($this->any())->method('getName')->will($this->returnValue('FooPropTable'));
     $proptable->expects($this->any())->method('isFixedPropertyTable')->will($this->returnValue($isFixedPropertyTable));
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $store->expects($this->once())->method('findPropertyTableID')->will($this->returnValue('Foo'));
     $store->expects($this->once())->method('getPropertyTables')->will($this->returnValue(array('Foo' => $proptable)));
     $store->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $store->expects($this->any())->method('getObjectIds')->will($this->returnValue($objectIds));
     $store->expects($this->any())->method('getDataItemHandlerForDIType')->will($this->returnValue($dataItemHandler));
     $queryEngineFactory = new QueryEngineFactory($store);
     $querySegmentListBuilder = $queryEngineFactory->newQuerySegmentListBuilder();
     $querySegmentListBuilder->setSortKeys($sortKeys);
     $instance = new SomePropertyInterpreter($querySegmentListBuilder);
     $this->assertTrue($instance->canInterpretDescription($description));
     $this->querySegmentValidator->assertThatContainerHasProperties($expected, $instance->interpretDescription($description));
 }