You are here

public function IndexResourceTest::filterDataProvider in JSON:API Search API 8

Filter data provider.

Return value

\Generator The data.

File

tests/src/Functional/IndexResourceTest.php, line 226

Class

IndexResourceTest
Tests index resource..

Namespace

Drupal\Tests\jsonapi_search_api\Functional

Code

public function filterDataProvider() : \Generator {
  (yield [
    [
      'filter' => [
        'category' => 'item_category',
      ],
    ],
    2,
    [
      1,
      2,
    ],
    [],
  ]);
  (yield [
    [
      'filter' => [
        'category' => [
          'operator' => '<>',
          'value' => 'item_category',
        ],
      ],
    ],
    3,
    [
      3,
      4,
      5,
    ],
    [],
  ]);
  (yield [
    [
      'filter' => [
        'id' => [
          'operator' => '>',
          'value' => '3',
        ],
      ],
    ],
    2,
    [
      4,
      5,
    ],
    [],
  ]);
  (yield [
    [
      'filter' => [
        'category' => [
          'operator' => 'IN',
          'value' => [
            'item_category',
            'article_category',
          ],
        ],
      ],
    ],
    4,
    [
      1,
      2,
      4,
      5,
    ],
    [],
  ]);
  (yield [
    [
      'filter' => [
        'category' => [
          'operator' => 'NOT IN',
          'value' => [
            'item_category',
            'article_category',
          ],
        ],
      ],
    ],
    1,
    [
      3,
    ],
    [],
  ]);
  (yield [
    [
      'filter' => [
        'keywords' => 'strawberry',
      ],
    ],
    2,
    [
      4,
      5,
    ],
    [],
  ]);
  (yield [
    [
      'filter' => [
        'keywords' => 'banana',
      ],
    ],
    1,
    [
      5,
    ],
    [],
  ]);
  (yield [
    [
      'filter' => [
        'keywords' => 'orange',
      ],
    ],
    3,
    [
      1,
      2,
      5,
    ],
    [],
  ]);
}