wiki.techinc.nl/tests/phpunit/includes/search/SearchNearMatcherTest.php
Aaron Schulz c4d9d51506 Clear the title cache in MutableRevisionRecordTest
Also do so in various other test classes.

Follows-up 170c49d61c. Fixes Travis CI regression:

> 1) MediaWiki\Tests\Revision\MutableRevisionRecordTest::testSetGetPageId
> Failed asserting that 2 is identical to 0.
> tests/phpunit/includes/Revision/MutableRevisionRecordTest.php:129

Change-Id: I41c8bda8e620ebe7608a393d81f3b0f13af68ba7
2018-10-25 21:16:27 +00: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 );
}
function tearDown() {
Title::clearCaches();
parent::tearDown();
}
}