You are here

public function SearchApiDateTest::testEmptyResults in Facets 8

Tests string query type without results.

File

tests/src/Kernel/Plugin/query_type/SearchApiDateTest.php, line 281

Class

SearchApiDateTest
Kernel test for date query type.

Namespace

Drupal\Tests\facets\Kernel\Plugin\query_type

Code

public function testEmptyResults() {
  $query = new SearchApiQuery([], 'search_api_query', []);
  $facet = new Facet([], 'facets_facet');
  $facet
    ->addProcessor([
    'processor_id' => 'date_item',
    'weights' => [],
    'settings' => [
      'granularity' => SearchApiDate::FACETAPI_DATE_YEAR,
      'date_format' => '',
      'date_display' => 'actual_date',
    ],
  ]);
  $query_type = new SearchApiDate([
    'facet' => $facet,
    'query' => $query,
  ], 'search_api_string', []);
  $built_facet = $query_type
    ->build();
  $this
    ->assertInstanceOf(FacetInterface::class, $built_facet);
  $results = $built_facet
    ->getResults();
  $this
    ->assertSame('array', gettype($results));
  $this
    ->assertEmpty($results);
}