protected function setUp() { parent::setUp(); if (!$this->isWikitextNS(NS_MAIN)) { $this->markTestSkipped('Main namespace does not support wikitext.'); } // Avoid special pages from extensions interferring with the tests $this->setMwGlobals('wgSpecialPages', array()); $this->search = SearchEngine::create(); $this->search->setNamespaces(array()); }
protected function setUp() { parent::setUp(); if (!$this->isWikitextNS(NS_MAIN)) { $this->markTestSkipped('Main namespace does not support wikitext.'); } // Avoid special pages from extensions interferring with the tests $this->setMwGlobals(['wgSpecialPages' => [], 'wgHooks' => []]); $this->search = MediaWikiServices::getInstance()->newSearchEngine(); $this->search->setNamespaces([]); $this->originalHandlers = TestingAccessWrapper::newFromClass('Hooks')->handlers; TestingAccessWrapper::newFromClass('Hooks')->handlers = []; SpecialPageFactory::resetList(); }
public function testAugmentorSearch() { $this->search->setNamespaces([0, 1, 4]); $resultSet = $this->search->searchText('smithee'); // Not using mock since PHPUnit mocks do not work properly with references in params $this->mergeMwGlobalArrayValue('wgHooks', ['SearchResultsAugment' => [[$this, 'addAugmentors']]]); $this->search->augmentSearchResults($resultSet); for ($result = $resultSet->next(); $result; $result = $resultSet->next()) { $id = $result->getTitle()->getArticleID(); $augmentData = "Result:{$id}:" . $result->getTitle()->getText(); $augmentData2 = "Result2:{$id}:" . $result->getTitle()->getText(); $this->assertEquals(['testSet' => $augmentData, 'testRow' => $augmentData2], $result->getExtensionData()); } }
public function testTextTitlePowerSearch() { $this->search->setNamespaces(array(0, 1, 4)); $this->assertEquals(array('Alan Smithee', 'Smithee', 'Talk:Smithee'), $this->fetchIds($this->search->searchTitle('smithee')), "Title power search failed"); }