Merge "selenium: invoke jobs to enforce eventual consistency"
[lhc/web/wiklou.git] / tests / phpunit / includes / search / SearchNearMatcherTest.php
1 <?php
2
3 /**
4 * @covers SearchNearMatcher
5 */
6 class 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
15 /**
16 * @dataProvider nearMatchProvider
17 */
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 }