protected function BackendTestBase::regressionTest2809753 in Search API 8
Regression test for multiple facets.
See also
https://www.drupal.org/node/2809753
1 call to BackendTestBase::regressionTest2809753()
- BackendTestBase::regressionTests in tests/
src/ Kernel/ BackendTestBase.php - Executes regression tests for issues that were already fixed.
File
- tests/
src/ Kernel/ BackendTestBase.php, line 786
Class
- BackendTestBase
- Provides a base class for backend tests.
Namespace
Drupal\Tests\search_api\KernelCode
protected function regressionTest2809753() {
$query = $this
->buildSearch();
$condition_group = $query
->createConditionGroup('OR', [
'facet:type',
]);
$condition_group
->addCondition('type', 'article');
$query
->addConditionGroup($condition_group);
$facets['type'] = [
'field' => 'type',
'limit' => 0,
'min_count' => 1,
'missing' => FALSE,
'operator' => 'or',
];
$facets['category'] = [
'field' => 'category',
'limit' => 0,
'min_count' => 1,
'missing' => FALSE,
'operator' => 'or',
];
$query
->setOption('search_api_facets', $facets);
$results = $query
->execute();
$this
->assertResults([
4,
5,
], $results, 'Multi-facets query');
$expected = [
[
'count' => 3,
'filter' => '"item"',
],
[
'count' => 2,
'filter' => '"article"',
],
];
$type_facets = $results
->getExtraData('search_api_facets')['type'];
usort($type_facets, [
$this,
'facetCompare',
]);
$this
->assertEquals($expected, $type_facets, 'Correct facets were returned for first facet');
$expected = [
[
'count' => 2,
'filter' => '"article_category"',
],
];
$category_facets = $results
->getExtraData('search_api_facets')['category'];
$this
->assertEquals($expected, $category_facets, 'Correct facets were returned for second facet');
}