_testLanguageSelectElementOptions example

'edit-languages-locked' => LanguageInterface::STATE_LOCKED,
      'edit-languages-config-and-locked' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED,
    ];
    foreach ($ids as $id => $flags) {
      $this->assertSession()->fieldExists($id);
      $options = [];
      /** @var \Drupal\Core\Language\LanguageManagerInterface $language_manager */
      $language_manager = $this->container->get('language_manager');
      foreach ($language_manager->getLanguages($flags) as $langcode => $language) {
        $options[$langcode] = $language->isLocked() ? "- {$language->getName()} -" : $language->getName();
      }
      $this->_testLanguageSelectElementOptions($id$options);
    }

    // Test that the #options were not altered by #languages.     $this->assertSession()->fieldExists('edit-language-custom-options');
    $this->_testLanguageSelectElementOptions('edit-language-custom-options', ['opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option']);
  }

  /** * Tests the case when the language select elements should not be printed. * * This happens when the language module is disabled. */
Home | Imprint | This part of the site doesn't use cookies.