WebformViewsSortTestBase.php in Webform Views Integration 8.5
File
tests/src/Kernel/sort/WebformViewsSortTestBase.php
View source
<?php
namespace Drupal\Tests\webform_views\Kernel\sort;
use Drupal\Tests\webform_views\Kernel\WebformViewsTestBase;
abstract class WebformViewsSortTestBase extends WebformViewsTestBase {
public function testSort($order, $expected) {
$this->webform = $this
->createWebform($this->webform_elements);
$this
->createWebformSubmissions($this->webform_submissions_data, $this->webform);
$view_handlers = $this->view_handlers;
$view_handlers['sort'][0]['options']['order'] = $order;
$this->view = $this
->initView($this->webform, $view_handlers);
$rendered_cells = $this
->renderView($this->view);
$this
->assertSame($expected, $rendered_cells, 'Sorting works for ' . $order . ' order');
}
public function providerSort() {
$tests = [];
$tests[] = [
'ASC',
$this->webform_submissions_data,
];
$tests[] = [
'DESC',
array_reverse($this->webform_submissions_data),
];
return $tests;
}
}