protected function ViewsTest::checkResultsOrder in Search API 8
Checks whether Views results are in a certain order in the sorts test view.
Parameters
array $query: The GET parameters to set for the view.
int[] $expected_results: The IDs of the expected results.
See also
views.view.search_api_test_sorts.yml
1 call to ViewsTest::checkResultsOrder()
- ViewsTest::testViewSorts in tests/
src/ Functional/ ViewsTest.php - Tests results are ordered correctly and react to exposed sorts.
File
- tests/
src/ Functional/ ViewsTest.php, line 660
Class
- ViewsTest
- Tests the Views integration of the Search API.
Namespace
Drupal\Tests\search_api\FunctionalCode
protected function checkResultsOrder(array $query, array $expected_results) {
$this
->drupalGet('search-api-test-sorts', [
'query' => $query,
]);
$web_assert = $this
->assertSession();
$rows_xpath = '//div[contains(@class, "views-row")]';
$web_assert
->elementsCount('xpath', $rows_xpath, count($expected_results));
foreach (array_values($expected_results) as $i => $id) {
$entity_label = Html::escape($this->entities[$id]
->label());
// XPath offsets are 1-based, not 0-based.
++$i;
$web_assert
->elementContains('xpath', "({$rows_xpath})[{$i}]", $entity_label);
}
}