wiki.techinc.nl/tests/phpunit/includes/search/SearchNearMatcherTest.php
Umherirrender 5bd311b1a2 Add public as visibility in tests folder
Add public, protected or private to function missing a visibility
Enable the tests folder for the phpcs sniff

Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
2019-10-10 21:55:37 +02:00

35 lines
1 KiB
PHP

<?php
/**
* @covers SearchNearMatcher
*/
class SearchNearMatcherTest extends \PHPUnit\Framework\TestCase {
public function nearMatchProvider() {
return [
'empty request returns nothing' => [ null, 'en', '' ],
'default behaviour' => [ 'Near Match Test', 'en', 'near match test' ],
'with a hash returns nothing' => [ null, 'en', '#near match test' ],
];
}
/**
* @dataProvider nearMatchProvider
*/
public function testNearMatch( $expected, $langCode, $searchterm ) {
$linkCache = MediaWiki\MediaWikiServices::getInstance()->getLinkCache();
$linkCache->addGoodLinkObj( 42, Title::newFromText( 'Near Match Test' ) );
$config = new HashConfig( [
'EnableSearchContributorsByIP' => false,
] );
$lang = Language::factory( $langCode );
$matcher = new SearchNearMatcher( $config, $lang );
$title = $matcher->getNearMatch( $searchterm );
$this->assertEquals( $expected, $title === null ? null : (string)$title );
}
public function tearDown() {
Title::clearCaches();
parent::tearDown();
}
}