function FieldLanguageTest::testField

Same name in other branches
  1. 9 core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php \Drupal\Tests\language\Kernel\Views\FieldLanguageTest::testField()
  2. 8.9.x core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php \Drupal\Tests\language\Kernel\Views\FieldLanguageTest::testField()
  3. 11.x core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php \Drupal\Tests\language\Kernel\Views\FieldLanguageTest::testField()

Tests the language field.

File

core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php, line 27

Class

FieldLanguageTest
Tests the field language handler.

Namespace

Drupal\Tests\language\Kernel\Views

Code

public function testField() : void {
    $view = Views::getView('test_view');
    $view->setDisplay();
    $view->displayHandlers
        ->get('default')
        ->overrideOption('fields', [
        'langcode' => [
            'id' => 'langcode',
            'table' => 'views_test_data',
            'field' => 'langcode',
        ],
    ]);
    $this->executeView($view);
    $this->assertEquals('English', $view->field['langcode']
        ->advancedRender($view->result[0]));
    $this->assertEquals('Lolspeak', $view->field['langcode']
        ->advancedRender($view->result[1]));
}

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