4 * @covers SearchNearMatcher
6 class SearchNearMatcherTest
extends \PHPUnit\Framework\TestCase
{
7 public function nearMatchProvider() {
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' ],
16 * @dataProvider nearMatchProvider
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,
24 $lang = Language
::factory( $langCode );
25 $matcher = new SearchNearMatcher( $config, $lang );
27 $title = $matcher->getNearMatch( $searchterm );
28 $this->assertEquals( $expected, $title === null ?
null : (string)$title );