X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fspecials%2FSpecialSearchTest.php;h=a4e4df166f1e90b931df268d68c0ba5f770fd1c9;hb=75cdcc94007dca953927b13db411aac94750b074;hp=f32eeca57eddb146603c73b29d3d25bb842b40c0;hpb=25c9157bca911120b578ace6147582f37c04b333;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/specials/SpecialSearchTest.php b/tests/phpunit/includes/specials/SpecialSearchTest.php index f32eeca57e..a4e4df166f 100644 --- a/tests/phpunit/includes/specials/SpecialSearchTest.php +++ b/tests/phpunit/includes/specials/SpecialSearchTest.php @@ -44,24 +44,24 @@ class SpecialSearchTest extends MediaWikiTestCase { * after an assertion fail. */ $this->assertEquals( - array( /** Expected: */ + [ /** Expected: */ 'ProfileName' => $expectedProfile, 'Namespaces' => $expectedNS, - ), - array( /** Actual: */ + ], + [ /** Actual: */ 'ProfileName' => $search->getProfile(), 'Namespaces' => $search->getNamespaces(), - ), + ], $message ); } public static function provideSearchOptionsTests() { $defaultNS = SearchEngine::defaultNamespaces(); - $EMPTY_REQUEST = array(); + $EMPTY_REQUEST = []; $NO_USER_PREF = null; - return array( + return [ /** * Parameters: * , @@ -69,28 +69,28 @@ class SpecialSearchTest extends MediaWikiTestCase { * , * Then an optional message. */ - array( + [ $EMPTY_REQUEST, $NO_USER_PREF, 'default', $defaultNS, 'Bug 33270: No request nor user preferences should give default profile' - ), - array( - array( 'ns5' => 1 ), $NO_USER_PREF, - 'advanced', array( 5 ), + ], + [ + [ 'ns5' => 1 ], $NO_USER_PREF, + 'advanced', [ 5 ], 'Web request with specific NS should override user preference' - ), - array( - $EMPTY_REQUEST, array( + ], + [ + $EMPTY_REQUEST, [ 'searchNs2' => 1, 'searchNs14' => 1, - ) + array_fill_keys( array_map( function ( $ns ) { + ] + array_fill_keys( array_map( function ( $ns ) { return "searchNs$ns"; }, $defaultNS ), 0 ), - 'advanced', array( 2, 14 ), + 'advanced', [ 2, 14 ], 'Bug 33583: search with no option should honor User search preferences' . ' and have all other namespace disabled' - ), - ); + ], + ]; } /** @@ -115,9 +115,9 @@ class SpecialSearchTest extends MediaWikiTestCase { * https://gerrit.wikimedia.org/r/4841 */ public function testSearchTermIsNotExpanded() { - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgSearchType' => null, - ) ); + ] ); # Initialize [[Special::Search]] $search = new SpecialSearch(); @@ -143,29 +143,29 @@ class SpecialSearchTest extends MediaWikiTestCase { } public function provideRewriteQueryWithSuggestion() { - return array( - array( + return [ + [ 'With suggestion and no rewritten query shows did you mean', '/Did you mean: ]+>first suggestion/', - new SpecialSearchTestMockResultSet( 'first suggestion', null, array( + new SpecialSearchTestMockResultSet( 'first suggestion', null, [ SearchResult::newFromTitle( Title::newMainPage() ), - ) ), - ), + ] ), + ], - array( + [ 'With rewritten query informs user of change', '/Showing results for ]+>first suggestion/', - new SpecialSearchTestMockResultSet( 'asdf', 'first suggestion', array( + new SpecialSearchTestMockResultSet( 'asdf', 'first suggestion', [ SearchResult::newFromTitle( Title::newMainPage() ), - ) ), - ), + ] ), + ], - array( + [ 'When both queries have no results user gets no results', '/There were no results matching the query/', - new SpecialSearchTestMockResultSet( 'first suggestion', 'first suggestion', array() ), - ), - ); + new SpecialSearchTestMockResultSet( 'first suggestion', 'first suggestion', [] ), + ], + ]; } /** @@ -174,7 +174,7 @@ class SpecialSearchTest extends MediaWikiTestCase { public function testRewriteQueryWithSuggestion( $message, $expectRegex, $results ) { $mockSearchEngine = $this->mockSearchEngine( $results ); $search = $this->getMockBuilder( 'SpecialSearch' ) - ->setMethods( array( 'getSearchEngine' ) ) + ->setMethods( [ 'getSearchEngine' ] ) ->getMock(); $search->expects( $this->any() ) ->method( 'getSearchEngine' ) @@ -193,7 +193,7 @@ class SpecialSearchTest extends MediaWikiTestCase { protected function mockSearchEngine( $results ) { $mock = $this->getMockBuilder( 'SearchEngine' ) - ->setMethods( array( 'searchText', 'searchTitle' ) ) + ->setMethods( [ 'searchText', 'searchTitle' ] ) ->getMock(); $mock->expects( $this->any() ) @@ -211,7 +211,7 @@ class SpecialSearchTestMockResultSet extends SearchResultSet { public function __construct( $suggestion = null, $rewrittenQuery = null, - array $results = array(), + array $results = [], $containedSyntax = false ) { $this->suggestion = $suggestion;