public function StringSorterTest::testDesc in Views XML Backend 8
File
- tests/
src/ Unit/ Sorter/ StringSorterTest.php, line 38
Class
- StringSorterTest
- @coversDefaultClass \Drupal\Tests\views_xml_backend\Unit\Sorter\StringSorterTest @group views_xml_backend
Namespace
Drupal\Tests\views_xml_backend\Unit\SorterCode
public function testDesc() {
$sorter = $this
->getSorter('field', 'DESC');
$result = [
new ResultRow([
'field' => [
'5',
],
'index' => 0,
]),
new ResultRow([
'field' => [
'4',
],
'index' => 1,
]),
new ResultRow([
'field' => [
'1',
],
'index' => 2,
]),
new ResultRow([
'field' => [
'1',
],
'index' => 3,
]),
new ResultRow([
'field' => [
'3',
],
'index' => 4,
]),
new ResultRow([
'field' => [
'2',
],
'index' => 5,
]),
];
$sorter($result);
$values = [
0 => '5',
1 => '4',
4 => '3',
5 => '2',
2 => '1',
3 => '1',
];
foreach ($values as $index => $value) {
$row = array_shift($result);
$this
->assertSame([
$value,
], $row->field);
$this
->assertSame($index, $row->index);
}
}