You are here

public function HighlightTest::testPostprocessSearchResultsWithEmptyResult in Search API 8

Tests postprocessing with an empty result set.

File

tests/src/Unit/Processor/HighlightTest.php, line 88

Class

HighlightTest
Tests the "Highlight" processor.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

public function testPostprocessSearchResultsWithEmptyResult() {
  $query = $this
    ->createMock(QueryInterface::class);
  $results = $this
    ->getMockBuilder(ResultSet::class)
    ->setMethods([
    'getResultCount',
    'getQuery',
    'getResultItems',
  ])
    ->setConstructorArgs([
    $query,
  ])
    ->getMock();
  $results
    ->expects($this
    ->once())
    ->method('getResultCount')
    ->will($this
    ->returnValue(0));
  $results
    ->expects($this
    ->once())
    ->method('getQuery')
    ->willReturn(NULL);
  $results
    ->expects($this
    ->never())
    ->method('getResultItems');

  /** @var \Drupal\search_api\Query\ResultSet $results */
  $this->processor
    ->postprocessSearchResults($results);
}