function LanguageSelectWidgetTest::testWithoutIncludedLockedLanguage

Same name in other branches
  1. 9 core/modules/language/tests/src/Kernel/LanguageSelectWidgetTest.php \Drupal\Tests\language\Kernel\LanguageSelectWidgetTest::testWithoutIncludedLockedLanguage()
  2. 8.9.x core/modules/language/tests/src/Kernel/LanguageSelectWidgetTest.php \Drupal\Tests\language\Kernel\LanguageSelectWidgetTest::testWithoutIncludedLockedLanguage()
  3. 10 core/modules/language/tests/src/Kernel/LanguageSelectWidgetTest.php \Drupal\Tests\language\Kernel\LanguageSelectWidgetTest::testWithoutIncludedLockedLanguage()

Tests the widget without the locked languages.

File

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

Class

LanguageSelectWidgetTest
Tests the language select widget.

Namespace

Drupal\Tests\language\Kernel

Code

public function testWithoutIncludedLockedLanguage() : void {
    $this->entityFormDisplay
        ->setComponent('langcode', [
        'type' => 'language_select',
        'settings' => [
            'include_locked' => FALSE,
        ],
    ])
        ->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',
    ], $options);
}

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