public function SortTranslationTest::testSortbyUntranslatedIntegerField in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/Handler/SortTranslationTest.php \Drupal\Tests\views\Kernel\Handler\SortTranslationTest::testSortbyUntranslatedIntegerField()
- 10 core/modules/views/tests/src/Kernel/Handler/SortTranslationTest.php \Drupal\Tests\views\Kernel\Handler\SortTranslationTest::testSortbyUntranslatedIntegerField()
Tests sorting on an untranslated field.
File
- core/
modules/ views/ tests/ src/ Kernel/ Handler/ SortTranslationTest.php, line 98
Class
- SortTranslationTest
- Tests sorting on translatable and not translatable fields.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testSortbyUntranslatedIntegerField() {
$map = [
'nid' => 'nid',
'node_field_data_langcode' => 'langcode',
];
$view = Views::getView('test_view_sort_translation');
$view
->setDisplay('default');
$this
->executeView($view);
// With ascending sort, the nodes should come out in reverse order.
$expected = [
[
'nid' => 3,
'langcode' => 'en',
],
[
'nid' => 2,
'langcode' => 'en',
],
[
'nid' => 1,
'langcode' => 'en',
],
];
$this
->assertIdenticalResultset($view, $expected, $map);
$view
->destroy();
$view = Views::getView('test_view_sort_translation');
$view
->setDisplay('display_de');
$this
->executeView($view);
$expected = [
[
'nid' => 3,
'langcode' => 'de',
],
[
'nid' => 2,
'langcode' => 'de',
],
[
'nid' => 1,
'langcode' => 'de',
],
];
// The weight field is not translated, we sort by it so the nodes
// should come out in the same order in both languages.
$this
->assertIdenticalResultset($view, $expected, $map);
$view
->destroy();
}