You are here

public function HighlightTest::testPostprocessSearchResultsWithoutKeywords in Search API 8

Tests postprocessing on a query without keywords.

File

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

Class

HighlightTest
Tests the "Highlight" processor.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

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

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