public function testSearchForGeographicCoordinateValueAsTerm() { if (!defined('SM_VERSION')) { $this->markTestSkipped("Requires 'Geographic coordinate' to be a supported data type (see Semantic Maps)"); } $propertyPage = Title::newFromText('Has coordinates', SMW_NS_PROPERTY); $targetPage = Title::newFromText(__METHOD__); $pageCreator = new PageCreator(); $pageCreator->createPage($propertyPage)->doEdit('[[Has type::Geographic coordinate]]'); $pageCreator->createPage($targetPage)->doEdit("[[Has coordinates::52°31'N, 13°24'E]]"); $search = new Search(); $results = $search->searchTitle("[[Has coordinates::52°31'N, 13°24'E]]"); $this->assertInstanceOf('\\SMW\\MediaWiki\\Search\\SearchResultSet', $results); if (is_a($this->getStore(), '\\SMW\\SPARQLStore\\SPARQLStore')) { $this->markTestIncomplete("Test was marked as incomplete because the SPARQLStore doesn't support the Geo data type"); } $this->assertEquals(1, $results->getTotalHits()); $pageDeleter = new PageDeleter(); $pageDeleter->deletePage($targetPage); $pageDeleter->deletePage($propertyPage); }
public function testSearchTitle_withSemanticQuery() { $term = '[[Some string that can be interpreted as a semantic query]]'; $queryResult = $this->getMockBuilder('\\SMWQueryResult')->disableOriginalConstructor()->getMock(); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->exactly(2))->method('getQueryResult')->will($this->returnCallback(function (SMWQuery $query) use($queryResult) { return $query->querymode === SMWQuery::MODE_COUNT ? 9001 : $queryResult; })); ApplicationFactory::getInstance()->registerObject('Store', $store); $search = new Search(); $result = $search->searchTitle($term); $this->assertInstanceOf('SMW\\MediaWiki\\Search\\SearchResultSet', $result); $this->assertEquals(9001, $result->getTotalHits()); }