<?php
+
use MediaWiki\MediaWikiServices;
+use Wikimedia\TestingAccessWrapper;
/**
* @group Search
$this->insertPage( 'Example Foo' );
$this->insertPage( 'Example Foo/Bar' );
$this->insertPage( 'Example/Baz' );
+ $this->insertPage( 'Sample' );
+ $this->insertPage( 'Sample Ban' );
+ $this->insertPage( 'Sample Eat' );
+ $this->insertPage( 'Sample Who' );
+ $this->insertPage( 'Sample Zoo' );
$this->insertPage( 'Redirect test', '#REDIRECT [[Redirect Test]]' );
$this->insertPage( 'Redirect Test' );
$this->insertPage( 'Redirect Test Worse Result' );
] ],
[ [
'Main namespace with title prefix',
- 'query' => 'Ex',
+ 'query' => 'Sa',
'results' => [
- 'Example',
- 'Example/Baz',
- 'Example Bar',
+ 'Sample',
+ 'Sample Ban',
+ 'Sample Eat',
],
// Third result when testing offset
'offsetresult' => [
- 'Example Foo',
+ 'Sample Who',
],
] ],
[ [
'results' => [
'Special:ActiveUsers',
'Special:AllMessages',
- 'Special:AllMyFiles',
+ 'Special:AllMyUploads',
],
// Third result when testing offset
'offsetresult' => [
- 'Special:AllMyUploads',
+ 'Special:AllPages',
],
] ],
[ [
],
// Third result when testing offset
'offsetresult' => [
- 'Special:UncategorizedImages',
+ 'Special:UncategorizedPages',
],
] ],
[ [
public function testSearch( array $case ) {
$this->search->setLimitOffset( 3 );
$results = $this->search->defaultPrefixSearch( $case['query'] );
- $results = array_map( function( Title $t ) {
+ $results = array_map( function ( Title $t ) {
return $t->getPrefixedText();
}, $results );
+
$this->assertEquals(
$case['results'],
$results,
public function testSearchWithOffset( array $case ) {
$this->search->setLimitOffset( 3, 1 );
$results = $this->search->defaultPrefixSearch( $case['query'] );
- $results = array_map( function( Title $t ) {
+ $results = array_map( function ( Title $t ) {
return $t->getPrefixedText();
}, $results );
],
] ],
[ [
- 'Exact match not on top (bug 70958)',
+ 'Exact match not on top (T72958)',
'provision' => [
'Barcelona',
'Bar',
],
] ],
[ [
- 'Exact match missing (bug 70958)',
+ 'Exact match missing (T72958)',
'provision' => [
'Barcelona',
'Barbara',
$search->setLimitOffset( 3 );
$results = $search->completionSearch( $case['query'] );
- $results = $results->map( function( SearchSuggestion $s ) {
+ $results = $results->map( function ( SearchSuggestion $s ) {
return $s->getText();
} );