public function testSetGetLimitForUpperboundWhereLimitIsUnrestricted() { $description = $this->getMockForAbstractClass('\\SMW\\Query\\Language\\Description'); $instance = new Query($description, Query::INLINE_QUERY); $upperboundLimit = 999999999; $this->assertLessThan($upperboundLimit, $this->smwgQMaxLimit); $this->assertLessThan($upperboundLimit, $this->smwgQMaxInlineLimit); $instance->setUnboundLimit($upperboundLimit); $this->assertEquals($upperboundLimit, $instance->getLimit()); }
public function testGetImmediateEmptyQueryResultForLimitLessThanOne() { $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock(); $this->store->expects($this->never())->method('getConnection')->will($this->returnValue($connection)); $this->querySegmentListBuilder->expects($this->any())->method('getErrors')->will($this->returnValue(array())); $description = $this->getMockForAbstractClass('\\SMW\\Query\\Language\\Description'); $instance = new QueryEngine($this->store, $this->querySegmentListBuilder, $this->querySegmentListProcessor, $this->engineOptions); $query = new Query($description); $query->setUnboundLimit(-1); $this->assertInstanceOf('\\SMWQueryResult', $instance->getQueryResult($query)); }
public function testTryTogetDependencyListFromForLimitZeroQuery() { $subject = DIWikiPage::newFromText('Foo'); $description = $this->getMockBuilder('\\SMW\\Query\\Language\\Description')->disableOriginalConstructor()->getMock(); $query = new Query($description); $query->setContextPage($subject); $query->setUnboundLimit(0); $queryResult = $this->getMockBuilder('\\SMWQueryResult')->disableOriginalConstructor()->getMock(); $queryResult->expects($this->any())->method('getQuery')->will($this->returnValue($query)); $queryResult->expects($this->never())->method('getStore')->will($this->returnValue($this->store)); $propertyHierarchyLookup = $this->getMockBuilder('\\SMW\\PropertyHierarchyLookup')->disableOriginalConstructor()->getMock(); $instance = new QueryResultDependencyListResolver($propertyHierarchyLookup); $this->assertEmpty($instance->getDependencyListFrom($queryResult)); }
public function testGetImmediateEmptyQueryResultForLimitLessThanOne() { $repositoryResult = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\RepositoryResult')->disableOriginalConstructor()->getMock(); $connection = $this->getMockBuilder('\\SMW\\SPARQLStore\\RepositoryConnection')->disableOriginalConstructor()->getMockForAbstractClass(); $store = $this->getMockBuilder('\\SMW\\SPARQLStore\\SPARQLStore')->disableOriginalConstructor()->getMock(); $compoundConditionBuilder = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\CompoundConditionBuilder')->disableOriginalConstructor()->getMock(); $compoundConditionBuilder->expects($this->never())->method('setSortKeys')->will($this->returnValue($compoundConditionBuilder)); $description = $this->getMockForAbstractClass('\\SMW\\Query\\Language\\Description'); $instance = new QueryEngine($connection, $compoundConditionBuilder, new QueryResultFactory($store)); $query = new Query($description); $query->setUnboundLimit(-1); $this->assertInstanceOf('\\SMWQueryResult', $instance->getQueryResult($query)); }
private function assertThatQueryReturns($queryString, $expected) { $description = $this->queryParser->getQueryDescription($queryString); $query = new Query($description, false, true); $query->sort = true; $query->sortkeys = array('Title' => 'desc'); $query->setUnboundLimit(1000); $this->queryResultValidator->assertThatQueryResultHasSubjects($expected, $this->getStore()->getQueryResult($query)); }