FieldLanguageTest.php

Same filename in other branches
  1. 9 core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php
  2. 10 core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php
  3. 11.x core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php

Namespace

Drupal\Tests\language\Kernel\Views

File

core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php

View source
<?php

namespace Drupal\Tests\language\Kernel\Views;

use Drupal\views\Views;

/**
 * Tests the field language handler.
 *
 * @group language
 * @see \Drupal\language\Plugin\views\field\Language
 */
class FieldLanguageTest extends LanguageTestBase {
    
    /**
     * Views used by this test.
     *
     * @var array
     */
    public static $testViews = [
        'test_view',
    ];
    
    /**
     * Tests the language field.
     */
    public function testField() {
        $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->assertEqual($view->field['langcode']
            ->advancedRender($view->result[0]), 'English');
        $this->assertEqual($view->field['langcode']
            ->advancedRender($view->result[1]), 'Lolspeak');
    }

}

Classes

Title Deprecated Summary
FieldLanguageTest Tests the field language handler.

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