function SortTranslationTest::testSortbyUntranslatedIntegerField
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Handler/SortTranslationTest.php \Drupal\Tests\views\Kernel\Handler\SortTranslationTest::testSortbyUntranslatedIntegerField()
- 8.9.x core/modules/views/tests/src/Kernel/Handler/SortTranslationTest.php \Drupal\Tests\views\Kernel\Handler\SortTranslationTest::testSortbyUntranslatedIntegerField()
- 11.x 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 102
Class
- SortTranslationTest
- Tests sorting on translatable and not translatable fields.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testSortbyUntranslatedIntegerField() : void {
$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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.