You are here

class FieldLanguageTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php \Drupal\Tests\language\Kernel\Views\FieldLanguageTest
  2. 9 core/modules/language/tests/src/Kernel/Views/FieldLanguageTest.php \Drupal\Tests\language\Kernel\Views\FieldLanguageTest

Tests the field language handler.

@group language

Hierarchy

Expanded class hierarchy of FieldLanguageTest

See also

\Drupal\language\Plugin\views\field\Language

File

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

Namespace

Drupal\Tests\language\Kernel\Views
View source
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
      ->assertEquals('English', $view->field['langcode']
      ->advancedRender($view->result[0]));
    $this
      ->assertEquals('Lolspeak', $view->field['langcode']
      ->advancedRender($view->result[1]));
  }

}

Members