You are here

protected function BackendTestBase::regressionTest2040543 in Search API 8

Regression tests for (none) facet shown when feature is set to "no".

See also

https://www.drupal.org/node/2040543

1 call to BackendTestBase::regressionTest2040543()
BackendTestBase::regressionTests in tests/src/Kernel/BackendTestBase.php
Executes regression tests for issues that were already fixed.

File

tests/src/Kernel/BackendTestBase.php, line 527

Class

BackendTestBase
Provides a base class for backend tests.

Namespace

Drupal\Tests\search_api\Kernel

Code

protected function regressionTest2040543() {
  $query = $this
    ->buildSearch();
  $facets['category'] = [
    'field' => 'category',
    'limit' => 0,
    'min_count' => 1,
    'missing' => TRUE,
  ];
  $query
    ->setOption('search_api_facets', $facets);
  $query
    ->range(0, 0);
  $results = $query
    ->execute();
  $expected = [
    [
      'count' => 2,
      'filter' => '"article_category"',
    ],
    [
      'count' => 2,
      'filter' => '"item_category"',
    ],
    [
      'count' => 1,
      'filter' => '!',
    ],
  ];
  $type_facets = $results
    ->getExtraData('search_api_facets')['category'];
  usort($type_facets, [
    $this,
    'facetCompare',
  ]);
  $this
    ->assertEquals($expected, $type_facets, 'Correct facets were returned');
  $query = $this
    ->buildSearch();
  $facets['category']['missing'] = FALSE;
  $query
    ->setOption('search_api_facets', $facets);
  $query
    ->range(0, 0);
  $results = $query
    ->execute();
  $expected = [
    [
      'count' => 2,
      'filter' => '"article_category"',
    ],
    [
      'count' => 2,
      'filter' => '"item_category"',
    ],
  ];
  $type_facets = $results
    ->getExtraData('search_api_facets')['category'];
  usort($type_facets, [
    $this,
    'facetCompare',
  ]);
  $this
    ->assertEquals($expected, $type_facets, 'Correct facets were returned');
}