You are here

protected function BackendTestBase::assertResults in Search API 8

Asserts that the given result set complies with expectations.

Parameters

int[] $result_ids: The expected result item IDs, as raw entity IDs.

\Drupal\search_api\Query\ResultSetInterface $results: The returned result set.

string $search_label: (optional) A label for the search to include in assertion messages.

string[] $ignored: (optional) The ignored keywords that should be present, if any.

string[] $warnings: (optional) The ignored warnings that should be present, if any.

25 calls to BackendTestBase::assertResults()
BackendTest::checkDbQueryAlter in modules/search_api_db/tests/src/Kernel/BackendTest.php
Checks whether the module's specific alter hook and event work correctly.
BackendTest::checkFieldIdChanges in modules/search_api_db/tests/src/Kernel/BackendTest.php
Checks that field ID changes are treated correctly (without re-indexing).
BackendTest::regressionTest2557291 in modules/search_api_db/tests/src/Kernel/BackendTest.php
Tests the case-sensitivity of fulltext searches.
BackendTest::regressionTest2873023 in modules/search_api_db/tests/src/Kernel/BackendTest.php
Tests whether keywords with special characters work correctly.
BackendTest::regressionTest2916534 in modules/search_api_db/tests/src/Kernel/BackendTest.php
Tests edge cases for partial matching.

... See full list

File

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

Class

BackendTestBase
Provides a base class for backend tests.

Namespace

Drupal\Tests\search_api\Kernel

Code

protected function assertResults(array $result_ids, ResultSetInterface $results, $search_label = 'Search', array $ignored = [], array $warnings = []) {
  $this
    ->assertEquals(count($result_ids), $results
    ->getResultCount(), "{$search_label} returned correct number of results.");
  if ($result_ids) {
    $this
      ->assertEquals($this
      ->getItemIds($result_ids), array_keys($results
      ->getResultItems()), "{$search_label} returned correct results.");
  }
  $this
    ->assertEquals($ignored, $results
    ->getIgnoredSearchKeys());
  $this
    ->assertEquals($warnings, $results
    ->getWarnings());
}