本文整理汇总了PHP中SearchEngine::setNamespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchEngine::setNamespaces方法的具体用法?PHP SearchEngine::setNamespaces怎么用?PHP SearchEngine::setNamespaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchEngine
的用法示例。
在下文中一共展示了SearchEngine::setNamespaces方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
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());
}
示例2: setUp
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();
}
示例3: testAugmentorSearch
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());
}
}
示例4: testTextTitlePowerSearch
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");
}