jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/343455 )

Change subject: Avoid database connection in SpecialSearchTest data provider
......................................................................


Avoid database connection in SpecialSearchTest data provider

SearchResult::newFromTitle involves database connnection,
thus better to avoid calling this in the data provider.

Change-Id: I891e97cf18ca1dd44abefe01731dfc5da51f1982
---
M tests/phpunit/includes/specials/SpecialSearchTest.php
1 file changed, 27 insertions(+), 9 deletions(-)

Approvals:
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, approved



diff --git a/tests/phpunit/includes/specials/SpecialSearchTest.php 
b/tests/phpunit/includes/specials/SpecialSearchTest.php
index 9daae97..4e9d826 100644
--- a/tests/phpunit/includes/specials/SpecialSearchTest.php
+++ b/tests/phpunit/includes/specials/SpecialSearchTest.php
@@ -150,23 +150,25 @@
                        [
                                'With suggestion and no rewritten query shows 
did you mean',
                                '/Did you mean: <a[^>]+>first suggestion/',
-                               new SpecialSearchTestMockResultSet( 'first 
suggestion', null, [
-                                       SearchResult::newFromTitle( 
Title::newMainPage() ),
-                               ] ),
+                               'first suggestion',
+                               null,
+                               [ Title::newMainPage() ]
                        ],
 
                        [
                                'With rewritten query informs user of change',
                                '/Showing results for <a[^>]+>first 
suggestion/',
-                               new SpecialSearchTestMockResultSet( 'asdf', 
'first suggestion', [
-                                       SearchResult::newFromTitle( 
Title::newMainPage() ),
-                               ] ),
+                               'asdf',
+                               'first suggestion',
+                               [ Title::newMainPage() ]
                        ],
 
                        [
                                'When both queries have no results user gets no 
results',
                                '/There were no results matching the query/',
-                               new SpecialSearchTestMockResultSet( 'first 
suggestion', 'first suggestion', [] ),
+                               'first suggestion',
+                               'first suggestion',
+                               []
                        ],
                ];
        }
@@ -174,8 +176,24 @@
        /**
         * @dataProvider provideRewriteQueryWithSuggestion
         */
-       public function testRewriteQueryWithSuggestion( $message, $expectRegex, 
$results ) {
-               $mockSearchEngine = $this->mockSearchEngine( $results );
+       public function testRewriteQueryWithSuggestion(
+               $message,
+               $expectRegex,
+               $suggestion,
+               $rewrittenQuery,
+               array $resultTitles
+       ) {
+               $results = array_map( function( $title ) {
+                       return SearchResult::newFromTitle( $title );
+               }, $resultTitles );
+
+               $searchResults = new SpecialSearchTestMockResultSet(
+                       $suggestion,
+                       $rewrittenQuery,
+                       $results
+               );
+
+               $mockSearchEngine = $this->mockSearchEngine( $searchResults );
                $search = $this->getMockBuilder( 'SpecialSearch' )
                        ->setMethods( [ 'getSearchEngine' ] )
                        ->getMock();

-- 
To view, visit https://gerrit.wikimedia.org/r/343455
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I891e97cf18ca1dd44abefe01731dfc5da51f1982
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Hashar <has...@free.fr>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to