You are here

function LanguageSelectElementTest::testHiddenLanguageSelectElement in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Form/LanguageSelectElementTest.php \Drupal\system\Tests\Form\LanguageSelectElementTest::testHiddenLanguageSelectElement()

Tests the case when the language select elements should not be printed.

This happens when the language module is disabled.

File

core/modules/system/src/Tests/Form/LanguageSelectElementTest.php, line 76
Contains \Drupal\system\Tests\Form\LanguageSelectElementTest.

Class

LanguageSelectElementTest
Tests that the language select form element prints and submits the right options.

Namespace

Drupal\system\Tests\Form

Code

function testHiddenLanguageSelectElement() {

  // Disable the language module, so that the language select field will not
  // be rendered.
  $this->container
    ->get('module_installer')
    ->uninstall(array(
    'language',
  ));
  $this
    ->drupalGet('form-test/language_select');

  // Check that the language fields were rendered on the page.
  $ids = array(
    'edit-languages-all',
    'edit-languages-configurable',
    'edit-languages-locked',
    'edit-languages-config-and-locked',
  );
  foreach ($ids as $id) {
    $this
      ->assertNoField($id, format_string('The @id field was not found on the page.', array(
      '@id' => $id,
    )));
  }

  // Check that the submitted values were the default values of the language
  // field elements.
  $edit = array();
  $this
    ->drupalPostForm(NULL, $edit, t('Submit'));
  $values = Json::decode($this
    ->getRawContent());
  $this
    ->assertEqual($values['languages_all'], 'xx');
  $this
    ->assertEqual($values['languages_configurable'], 'en');
  $this
    ->assertEqual($values['languages_locked'], LanguageInterface::LANGCODE_NOT_SPECIFIED);
  $this
    ->assertEqual($values['languages_config_and_locked'], 'dummy_value');
  $this
    ->assertEqual($values['language_custom_options'], 'opt2');
}