conceptQuerySegmentBuilder = $this->getMockBuilder( '\SMW\SQLStore\QueryEngine\ConceptQuerySegmentBuilder' ) ->disableOriginalConstructor() ->getMock(); $this->store = $this->getMockBuilder( SQLStore::class ) ->disableOriginalConstructor() ->getMock(); } public function testCanConstruct() { $this->assertInstanceOf( '\SMW\SQLStore\ConceptCache', new ConceptCache( $this->store, $this->conceptQuerySegmentBuilder ) ); } public function testRefreshConceptCache() { $this->conceptQuerySegmentBuilder->expects( $this->once() ) ->method( 'getErrors' ) ->willReturn( [] ); $instance = new ConceptCache( new SQLStore(), $this->conceptQuerySegmentBuilder ); $instance->refreshConceptCache( Title::newFromText( 'Foo', SMW_NS_CONCEPT ) ); } public function testDeleteConceptCache() { $connection = $this->getMockBuilder( '\SMW\MediaWiki\Connection\Database' ) ->disableOriginalConstructor() ->getMock(); $connection->expects( $this->any() ) ->method( 'selectRow' ) ->willReturn( false ); $connection->expects( $this->once() ) ->method( 'delete' ); $connectionManager = $this->getMockBuilder( '\SMW\Connection\ConnectionManager' ) ->disableOriginalConstructor() ->getMock(); $connectionManager->expects( $this->atLeastOnce() ) ->method( 'getConnection' ) ->willReturn( $connection ); $store = new SQLStore(); $store->setConnectionManager( $connectionManager ); $instance = new ConceptCache( $store, $this->conceptQuerySegmentBuilder ); $instance->deleteConceptCache( Title::newFromText( 'Foo', SMW_NS_CONCEPT ) ); } }