function RowEntityRenderersTest::checkLanguageRenderersRelationship

Same name in other branches
  1. 11.x core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php \Drupal\Tests\views\Kernel\Entity\RowEntityRenderersTest::checkLanguageRenderersRelationship()

Checks language renderer configurations work with relationships.

The Views with relationships filter and sort a little differently. First, they filter such that we only consider English nodes when finding relationships. If we didn't do this, we'd get 27 results in these Views, which is just way too much. Second, after sorting by the node title, we sort by the title of the referenced translation to have a predictable order.

Parameters

string $display: Name of display to test with.

array $values: An array of node information which are each an array of node titles associated with language keys appropriate for the translation of that node.

2 calls to RowEntityRenderersTest::checkLanguageRenderersRelationship()
RowEntityRenderersTest::testEntityRenderersRelationship in core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php
Tests the entity row renderers for relationships.
RowEntityRenderersTest::testFieldRenderersRelationship in core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php
Tests the field row renderers for relationships.

File

core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php, line 297

Class

RowEntityRenderersTest
Tests the entity row renderers.

Namespace

Drupal\Tests\views\Kernel\Entity

Code

protected function checkLanguageRenderersRelationship($display, $values) {
    $expected = [
        $values[1]['en'],
        $values[1]['en'],
        $values[1]['en'],
        $values[2]['en'],
        $values[2]['en'],
        $values[2]['en'],
        $values[0]['en'],
        $values[0]['en'],
        $values[0]['en'],
    ];
    $this->assertTranslations($display, '***LANGUAGE_language_content***', $expected, 'The current language renderer behaves as expected.');
    $expected = [
        $values[1]['l0'],
        $values[1]['l0'],
        $values[1]['l0'],
        $values[2]['l1'],
        $values[2]['l1'],
        $values[2]['l1'],
        $values[0]['en'],
        $values[0]['en'],
        $values[0]['en'],
    ];
    $this->assertTranslations($display, '***LANGUAGE_entity_default***', $expected, 'The default language renderer behaves as expected.');
    $expected = [
        $values[1]['en'],
        $values[1]['l0'],
        $values[1]['l1'],
        $values[2]['en'],
        $values[2]['l0'],
        $values[2]['l1'],
        $values[0]['en'],
        $values[0]['l0'],
        $values[0]['l1'],
    ];
    $this->assertTranslations($display, '***LANGUAGE_entity_translation***', $expected, 'The translation language renderer behaves as expected.');
    $expected = [
        $values[1][$this->langcodes[0]],
        $values[1][$this->langcodes[0]],
        $values[1][$this->langcodes[0]],
        $values[2][$this->langcodes[0]],
        $values[2][$this->langcodes[0]],
        $values[2][$this->langcodes[0]],
        $values[0][$this->langcodes[0]],
        $values[0][$this->langcodes[0]],
        $values[0][$this->langcodes[0]],
    ];
    $this->assertTranslations($display, '***LANGUAGE_site_default***', $expected, 'The site default language renderer behaves as expected.');
    $expected = [
        $values[1]['l0'],
        $values[1]['l0'],
        $values[1]['l0'],
        $values[2]['l0'],
        $values[2]['l0'],
        $values[2]['l0'],
        $values[0]['l0'],
        $values[0]['l0'],
        $values[0]['l0'],
    ];
    $this->assertTranslations($display, 'l0', $expected, 'The language specific renderer behaves as expected.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.