X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fsearch%2FSearchEngineTest.php;h=2561fd060f5df6df9babc7d9cba3bc85320f3c1a;hb=6508c760c29b9471662a4713bade6309d0693a1c;hp=e8077769e166e1bec25be0536f3893c42c8d9a52;hpb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php index e8077769e1..2561fd060f 100644 --- a/tests/phpunit/includes/search/SearchEngineTest.php +++ b/tests/phpunit/includes/search/SearchEngineTest.php @@ -84,10 +84,8 @@ class SearchEngineTest extends MediaWikiLangTestCase { $this->assertTrue( is_object( $results ) ); $matches = []; - $row = $results->next(); - while ( $row ) { + foreach ( $results as $row ) { $matches[] = $row->getTitle()->getPrefixedText(); - $row = $results->next(); } $results->free(); # Search is not guaranteed to return results in a certain order; @@ -173,7 +171,7 @@ class SearchEngineTest extends MediaWikiLangTestCase { public function testPhraseSearchHighlight() { $phrase = "smithee is one who smiths"; $res = $this->search->searchText( "\"$phrase\"" ); - $match = $res->next(); + $match = $res->getIterator()->current(); $snippet = "A " . $phrase . ""; $this->assertStringStartsWith( $snippet, $match->getTextSnippet( $res->termMatches() ), @@ -277,7 +275,7 @@ class SearchEngineTest extends MediaWikiLangTestCase { $this->mergeMwGlobalArrayValue( 'wgHooks', [ 'SearchResultsAugment' => [ [ $this, 'addAugmentors' ] ] ] ); $this->search->augmentSearchResults( $resultSet ); - for ( $result = $resultSet->next(); $result; $result = $resultSet->next() ) { + foreach ( $resultSet as $result ) { $id = $result->getTitle()->getArticleID(); $augmentData = "Result:$id:" . $result->getTitle()->getText(); $augmentData2 = "Result2:$id:" . $result->getTitle()->getText(); @@ -292,11 +290,10 @@ class SearchEngineTest extends MediaWikiLangTestCase { ->method( 'augmentAll' ) ->willReturnCallback( function ( SearchResultSet $resultSet ) { $data = []; - for ( $result = $resultSet->next(); $result; $result = $resultSet->next() ) { + foreach ( $resultSet as $result ) { $id = $result->getTitle()->getArticleID(); $data[$id] = "Result:$id:" . $result->getTitle()->getText(); } - $resultSet->rewind(); return $data; } ); $setAugmentors['testSet'] = $setAugmentor;