You are here

public function LanguageSelectWidgetTest::testWithIncludedLockedLanguage in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Kernel/LanguageSelectWidgetTest.php \Drupal\Tests\language\Kernel\LanguageSelectWidgetTest::testWithIncludedLockedLanguage()
  2. 10 core/modules/language/tests/src/Kernel/LanguageSelectWidgetTest.php \Drupal\Tests\language\Kernel\LanguageSelectWidgetTest::testWithIncludedLockedLanguage()

Tests the widget with the locked languages.

File

core/modules/language/tests/src/Kernel/LanguageSelectWidgetTest.php, line 53

Class

LanguageSelectWidgetTest
Tests the language select widget.

Namespace

Drupal\Tests\language\Kernel

Code

public function testWithIncludedLockedLanguage() {
  $this->entityFormDisplay
    ->setComponent('langcode', [
    'type' => 'language_select',
  ])
    ->save();
  $entity = EntityTest::create([
    'name' => $this
      ->randomString(),
  ]);
  $form = $this->container
    ->get('entity.form_builder')
    ->getForm($entity);
  $options = array_keys($form['langcode']['widget'][0]['value']['#options']);
  $this
    ->assertSame([
    'en',
    'und',
    'zxx',
  ], $options);
}