public function IndexFacetsTest::dataForFacets in JSON:API Search API 8
Daa provider for the test.
Return value
\Generator The test data.
File
- modules/
jsonapi_search_api_facets/ tests/ src/ Functional/ IndexFacetsTest.php, line 297
Class
- IndexFacetsTest
- Tests searching with facets.
Namespace
Drupal\Tests\jsonapi_search_api_facets\FunctionalCode
public function dataForFacets() : \Generator {
// Baseline with no query filter.
(yield [
[
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'or',
],
],
FALSE,
[],
5,
]);
(yield [
[
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'or',
],
],
FALSE,
[
'keywords' => 'grape',
],
3,
]);
(yield [
[
'keywords' => [
'name' => 'Keywords',
'alias' => 'f_keywords',
'query_operator' => 'or',
],
],
FALSE,
[
'f_keywords' => 'grape',
],
3,
]);
(yield [
[
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'or',
],
],
FALSE,
[
'keywords-filter' => [
'condition' => [
'path' => 'keywords',
'operator' => 'IN',
'value' => [
'grape',
'strawberry',
],
],
],
],
3,
]);
(yield [
[
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'and',
],
],
FALSE,
[
'keywords' => 'grape',
],
3,
]);
(yield [
[
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'and',
],
],
FALSE,
[
'keywords-filter' => [
'condition' => [
'path' => 'keywords',
'operator' => 'IN',
'value' => [
'grape',
'strawberry',
'banana',
],
],
],
],
1,
]);
(yield [
[
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'or',
],
],
TRUE,
[
'keywords' => 'apple',
],
2,
]);
(yield [
[
'category' => [
'name' => 'Category',
'query_operator' => 'or',
],
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'or',
],
],
FALSE,
[
'keywords' => 'apple',
'category' => 'item_category',
],
1,
]);
(yield [
[
'category' => [
'name' => 'Category',
'query_operator' => 'and',
],
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'and',
],
],
FALSE,
[
'keywords' => 'grape',
'category' => 'item_category',
],
1,
]);
(yield [
[
'category' => [
'name' => 'Category',
'query_operator' => 'or',
],
'keywords' => [
'name' => 'Keywords',
'query_operator' => 'or',
],
],
FALSE,
[
'keywords' => 'banana',
'category' => 'article_category',
],
1,
]);
}