function ViewsModerationStateSortTest::assertSortResults

Same name and namespace in other branches
  1. 8.9.x core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateSortTest.php \Drupal\Tests\content_moderation\Kernel\ViewsModerationStateSortTest::assertSortResults()
  2. 10 core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateSortTest.php \Drupal\Tests\content_moderation\Kernel\ViewsModerationStateSortTest::assertSortResults()
  3. 11.x core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateSortTest.php \Drupal\Tests\content_moderation\Kernel\ViewsModerationStateSortTest::assertSortResults()

Assert the order of a views sort result.

@internal

Parameters

string $view_id: The ID of the view.

string $column: The column associated with each row.

string $order: The sort order.

array $expected: The expected results array.

2 calls to ViewsModerationStateSortTest::assertSortResults()
ViewsModerationStateSortTest::testSortBaseTable in core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateSortTest.php
Tests sorting with a standard data base table.
ViewsModerationStateSortTest::testSortRevisionBaseTable in core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateSortTest.php
Tests sorting with the revision base table.

File

core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateSortTest.php, line 171

Class

ViewsModerationStateSortTest
Tests the views moderation_state field sorting integration.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

protected function assertSortResults(string $view_id, string $column, string $order, array $expected) : void {
    // Test with exposed input.
    $view = Views::getView($view_id);
    $view->setExposedInput([
        'sort_by' => 'moderation_state',
        'sort_order' => $order,
    ]);
    $view->execute();
    $this->assertIdenticalResultset($view, $expected, [
        $column => $column,
    ]);
    // Test click sorting.
    $view = Views::getView($view_id);
    $view->removeHandler('default', 'sort', 'moderation_state');
    $request = new Request([
        'order' => 'moderation_state',
        'sort' => strtolower($order),
    ]);
    $view->setRequest($request);
    $view->execute();
    $this->assertIdenticalResultset($view, $expected, [
        $column => $column,
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.