MediaWiki REL1_32
SearchNearMatcherTest.php
Go to the documentation of this file.
1<?php
2
6class SearchNearMatcherTest extends \PHPUnit\Framework\TestCase {
7 public function nearMatchProvider() {
8 return [
9 'empty request returns nothing' => [ null, 'en', '' ],
10 'default behaviour' => [ 'Near Match Test', 'en', 'near match test' ],
11 'with a hash returns nothing' => [ null, 'en', '#near match test' ],
12 ];
13 }
14
18 public function testNearMatch( $expected, $langCode, $searchterm ) {
19 $linkCache = MediaWiki\MediaWikiServices::getInstance()->getLinkCache();
20 $linkCache->addGoodLinkObj( 42, Title::newFromText( 'Near Match Test' ) );
21 $config = new HashConfig( [
22 'EnableSearchContributorsByIP' => false,
23 ] );
24 $lang = Language::factory( $langCode );
25 $matcher = new SearchNearMatcher( $config, $lang );
26
27 $title = $matcher->getNearMatch( $searchterm );
28 $this->assertEquals( $expected, $title === null ? null : (string)$title );
29 }
30}
A Config instance which stores all settings as a member variable.
testNearMatch( $expected, $langCode, $searchterm)
nearMatchProvider
Implementation of near match title search.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition hooks.txt:181
if(!isset( $args[0])) $lang