diff options
author | Erik Bernhardson <ebernhardson@wikimedia.org> | 2017-12-13 17:03:20 -0800 |
---|---|---|
committer | Erik Bernhardson <ebernhardson@wikimedia.org> | 2018-06-11 13:56:19 -0700 |
commit | 83bae78c3a78a56eb4bcbabdb2cd0e1670af89a1 (patch) | |
tree | bbc2541e57ceb4c4fb10063fd0b3b88423b194c2 /tests/phpunit/includes/api/ApiQueryPrefixSearchTest.php | |
parent | 2a43939ffb0cfb0808c2b56430be4f5e88d863ee (diff) | |
download | mediawikicore-83bae78c3a78a56eb4bcbabdb2cd0e1670af89a1.tar.gz mediawikicore-83bae78c3a78a56eb4bcbabdb2cd0e1670af89a1.zip |
Silently drop unknown titles in completion search
This mimics how full text works by silenty dropping results returned from
search that no longer exist. This could be because the search index is slightly
out of sync with reality, or the search engine could simply be broken.
Only silent from the users perspective. We maintain a count in statsd of
the number of titles dropped. This can be monitored over time to
recognize any increases.
Bug: T115756
Change-Id: I2f29d73e258cd448a14d35a2b4902a4fb6f61c68
Diffstat (limited to 'tests/phpunit/includes/api/ApiQueryPrefixSearchTest.php')
-rw-r--r-- | tests/phpunit/includes/api/ApiQueryPrefixSearchTest.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/phpunit/includes/api/ApiQueryPrefixSearchTest.php b/tests/phpunit/includes/api/ApiQueryPrefixSearchTest.php index ae5924d80056..749f1546042a 100644 --- a/tests/phpunit/includes/api/ApiQueryPrefixSearchTest.php +++ b/tests/phpunit/includes/api/ApiQueryPrefixSearchTest.php @@ -7,6 +7,23 @@ * @covers ApiQueryPrefixSearch */ class ApiQueryPrefixSearchTest extends ApiTestCase { + const TEST_QUERY = 'unittest'; + + public function setUp() { + parent::setUp(); + $this->setMwGlobals( [ + 'wgSearchType' => MockCompletionSearchEngine::class, + ] ); + MockCompletionSearchEngine::clearMockResults(); + $results = []; + foreach ( range( 0, 10 ) as $i ) { + $title = "Search_Result_$i"; + $results[] = $title; + $this->editPage( $title, 'hi there' ); + } + MockCompletionSearchEngine::addMockResults( self::TEST_QUERY, $results ); + } + public function offsetContinueProvider() { return [ 'no offset' => [ 2, 2, 0, 2 ], @@ -20,11 +37,10 @@ class ApiQueryPrefixSearchTest extends ApiTestCase { * @dataProvider offsetContinueProvider */ public function testOffsetContinue( $expectedOffset, $expectedResults, $offset, $limit ) { - $this->registerMockSearchEngine(); $response = $this->doApiRequest( [ 'action' => 'query', 'list' => 'prefixsearch', - 'pssearch' => 'example query terms', + 'pssearch' => self::TEST_QUERY, 'psoffset' => $offset, 'pslimit' => $limit, ] ); @@ -39,10 +55,4 @@ class ApiQueryPrefixSearchTest extends ApiTestCase { $this->assertEquals( $expectedOffset, $result['continue']['psoffset'] ); } } - - private function registerMockSearchEngine() { - $this->setMwGlobals( [ - 'wgSearchType' => MockCompletionSearchEngine::class, - ] ); - } } |