public function LanguageConfigurationElementTest::testLanguageConfigurationElement

Tests the language settings have been saved.

File

drupal/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php, line 36
Definition of Drupal\language\Tests\LanguageConfigurationElementTest.

Class

LanguageConfigurationElementTest
Functional tests for language configuration's effect on negotiation setup.

Namespace

Drupal\language\Tests

Code

public function testLanguageConfigurationElement() {
  $this
    ->drupalGet('language-tests/language_configuration_element');
  $edit['lang_configuration[langcode]'] = 'current_interface';
  $edit['lang_configuration[language_hidden]'] = TRUE;
  $this
    ->drupalPost(NULL, $edit, 'Save');
  $lang_conf = language_get_default_configuration('some_custom_type', 'some_bundle');

  // Check that the settings have been saved.
  $this
    ->assertEqual($lang_conf['langcode'], 'current_interface');
  $this
    ->assertTrue($lang_conf['language_hidden']);
  $this
    ->drupalGet('language-tests/language_configuration_element');
  $this
    ->assertOptionSelected('edit-lang-configuration-langcode', 'current_interface');
  $this
    ->assertFieldChecked('edit-lang-configuration-language-hidden');

  // Reload the page and save again.
  $this
    ->drupalGet('language-tests/language_configuration_element');
  $edit['lang_configuration[langcode]'] = 'authors_default';
  $edit['lang_configuration[language_hidden]'] = FALSE;
  $this
    ->drupalPost(NULL, $edit, 'Save');
  $lang_conf = language_get_default_configuration('some_custom_type', 'some_bundle');

  // Check that the settings have been saved.
  $this
    ->assertEqual($lang_conf['langcode'], 'authors_default');
  $this
    ->assertFalse($lang_conf['language_hidden']);
  $this
    ->drupalGet('language-tests/language_configuration_element');
  $this
    ->assertOptionSelected('edit-lang-configuration-langcode', 'authors_default');
  $this
    ->assertNoFieldChecked('edit-lang-configuration-language-hidden');
}