You are here

public function WebformViewsFieldTestBase::testClickSort in Webform Views Integration 8.5

Test click sorting functionality.

@dataProvider providerClickSort()

Parameters

string $field_handler_id: Field handler ID on which to initialize click sorting.

string $order: Order of the click sorting. Either 'asc' or 'desc'.

array $expected: Expected output from $this->renderView() with the specified above click sorting.

File

tests/src/Kernel/field/WebformViewsFieldTestBase.php, line 116

Class

WebformViewsFieldTestBase
Reasonable starting point for testing webform views field handlers.

Namespace

Drupal\Tests\webform_views\Kernel\field

Code

public function testClickSort($field_handler_id, $order, $expected) {
  $this->webform = $this
    ->createWebform($this->webform_elements);
  $this
    ->createWebformSubmissions($this->webform_submissions_data, $this->webform);
  $this->view = $this
    ->initView($this->webform, $this->view_handlers);
  $this->view
    ->getExecutable()
    ->build();
  $this->view
    ->getExecutable()->field[$field_handler_id]
    ->clickSort($order);
  $this->view
    ->getExecutable()->built = FALSE;
  $rendered_cells = $this
    ->renderView($this->view);
  $this
    ->assertSame($expected, $rendered_cells, 'Click sorting works for ' . $order . ' order');
}