getMockBuilder( '\SMW\Store' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->assertInstanceOf( '\SMW\MediaWiki\Specials\SearchByProperty\QueryResultLookup', new QueryResultLookup( $store ) ); } public function testDoQueryForNonValue() { $pageRequestOptions = new PageRequestOptions( 'Foo', [] ); $pageRequestOptions->initialize(); $store = $this->getMockBuilder( '\SMW\Store' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $store->expects( $this->once() ) ->method( 'getPropertyValues' ) ->with( $this->isType( 'null' ), $this->isInstanceOf( '\SMW\DIProperty' ), $this->anything() ) ->willReturn( [] ); $instance = new QueryResultLookup( $store ); $this->assertIsArray( $instance->doQuery( $pageRequestOptions ) ); } public function testDoQueryForExactValue() { $pageRequestOptions = new PageRequestOptions( 'Foo/Bar', [] ); $pageRequestOptions->initialize(); $store = $this->getMockBuilder( '\SMW\Store' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $store->expects( $this->once() ) ->method( 'getPropertySubjects' ) ->with( $this->isInstanceOf( '\SMW\DIProperty' ), $this->anything(), $this->anything() ) ->willReturn( [] ); $instance = new QueryResultLookup( $store ); $this->assertInternaltype( 'array', $instance->doQuery( $pageRequestOptions ) ); } public function testDoQueryForNearbyResults() { $pageRequestOptions = new PageRequestOptions( 'Foo/Bar', [] ); $pageRequestOptions->initialize(); $queryResult = $this->getMockBuilder( '\SMW\Query\QueryResult' ) ->disableOriginalConstructor() ->getMock(); $queryResult->expects( $this->any() ) ->method( 'getNext' ) ->willReturn( false ); $store = $this->getMockBuilder( '\SMW\Store' ) ->disableOriginalConstructor() ->getMockForAbstractClass(); $store->expects( $this->once() ) ->method( 'getQueryResult' ) ->with( $this->isInstanceOf( '\SMWQuery' ) ) ->willReturn( $queryResult ); $instance = new QueryResultLookup( $store ); $this->assertInternaltype( 'array', $instance->doQueryForNearbyResults( $pageRequestOptions, 1 ) ); } public function testDoQueryLinksReferences() { $idTable = $this->getMockBuilder( '\stdClass' ) ->setMethods( [ 'getId' ] ) ->getMock(); $idTable->expects( $this->atLeastOnce() ) ->method( 'getId' ) ->willReturnOnConsecutiveCalls( 42 ); $store = $this->getMockBuilder( '\SMW\SQLStore\SQLStore' ) ->disableOriginalConstructor() ->setMethods( [ 'getObjectIds' ] ) ->getMockForAbstractClass(); $store->expects( $this->any() ) ->method( 'getObjectIds' ) ->willReturn( $idTable ); $pageRequestOptions = new PageRequestOptions( 'Foo/Bar', [] ); $pageRequestOptions->initialize(); $instance = new QueryResultLookup( $store ); $this->assertInternaltype( 'array', $instance->doQueryLinksReferences( $pageRequestOptions, 1 ) ); } }