public function testDebugQueryResultForMockedCompostion() { // PHPUnit 3.7 goes drumming when trying to add a method on an // interface hence the use of the concrete class $connection = $this->getMockBuilder('\\SMW\\SPARQLStore\\RepositoryConnectors\\GenericHttpRepositoryConnector')->disableOriginalConstructor()->setMethods(array('getSparqlForSelect'))->getMock(); $connection->expects($this->once())->method('getSparqlForSelect')->will($this->returnValue('Foo')); $condition = $this->getMockForAbstractClass('\\SMW\\SPARQLStore\\QueryEngine\\Condition\\Condition'); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $compoundConditionBuilder = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\CompoundConditionBuilder')->disableOriginalConstructor()->getMock(); $compoundConditionBuilder->expects($this->any())->method('getErrors')->will($this->returnValue(array())); $compoundConditionBuilder->expects($this->atLeastOnce())->method('setSortKeys')->will($this->returnValue($compoundConditionBuilder)); $compoundConditionBuilder->expects($this->once())->method('getConditionFrom')->will($this->returnValue($condition)); $description = $this->getMockForAbstractClass('\\SMW\\Query\\Language\\Description'); $instance = new QueryEngine($connection, $compoundConditionBuilder, new QueryResultFactory($store)); $query = new Query($description); $query->querymode = Query::MODE_DEBUG; $this->assertInternalType('string', $instance->getQueryResult($query)); }
public function testInstanceQueryResultForMockedSingletonCompostion() { $repositoryResult = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\RepositoryResult')->disableOriginalConstructor()->getMock(); $connection = $this->getMockBuilder('\\SMW\\SPARQLStore\\RepositoryConnection')->disableOriginalConstructor()->setMethods(array('ask'))->getMockForAbstractClass(); $connection->expects($this->once())->method('ask')->will($this->returnValue($repositoryResult)); $condition = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\Condition\\SingletonCondition')->disableOriginalConstructor()->getMock(); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $compoundConditionBuilder = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\CompoundConditionBuilder')->disableOriginalConstructor()->getMock(); $compoundConditionBuilder->expects($this->any())->method('getErrors')->will($this->returnValue(array())); $compoundConditionBuilder->expects($this->atLeastOnce())->method('setSortKeys')->will($this->returnValue($compoundConditionBuilder)); $compoundConditionBuilder->expects($this->once())->method('buildCondition')->will($this->returnValue($condition)); $description = $this->getMockForAbstractClass('\\SMW\\Query\\Language\\Description'); $instance = new QueryEngine($connection, $compoundConditionBuilder, new QueryResultFactory($store)); $query = new Query($description); $this->assertInstanceOf('\\SMWQueryResult', $instance->getInstanceQueryResult($query)); }
public function testGetSuccessCountQueryResultForMockedCompostion() { $federateResultSet = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\FederateResultSet')->disableOriginalConstructor()->getMock(); $connection = $this->getMockBuilder('\\SMWSparqlDatabase')->disableOriginalConstructor()->getMock(); $connection->expects($this->once())->method('selectCount')->will($this->returnValue($federateResultSet)); $condition = $this->getMockForAbstractClass('\\SMW\\SPARQLStore\\QueryEngine\\Condition\\Condition'); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $compoundConditionBuilder = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\CompoundConditionBuilder')->disableOriginalConstructor()->getMock(); $compoundConditionBuilder->expects($this->atLeastOnce())->method('setSortKeys')->will($this->returnValue($compoundConditionBuilder)); $compoundConditionBuilder->expects($this->once())->method('buildCondition')->will($this->returnValue($condition)); $description = $this->getMockForAbstractClass('\\SMWDescription'); $instance = new QueryEngine($connection, $compoundConditionBuilder, new QueryResultFactory($store)); $this->assertInstanceOf('\\SMWQueryResult', $instance->getCountQueryResult(new Query($description))); }