function LanguageConfigurationElementTest::testLanguageConfigurationElement
Same name in other branches
- 9 core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php \Drupal\Tests\language\Functional\LanguageConfigurationElementTest::testLanguageConfigurationElement()
- 8.9.x core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php \Drupal\Tests\language\Functional\LanguageConfigurationElementTest::testLanguageConfigurationElement()
- 11.x core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php \Drupal\Tests\language\Functional\LanguageConfigurationElementTest::testLanguageConfigurationElement()
Tests the language settings have been saved.
File
-
core/
modules/ language/ tests/ src/ Functional/ LanguageConfigurationElementTest.php, line 52
Class
- LanguageConfigurationElementTest
- Tests the features of the language configuration element field.
Namespace
Drupal\Tests\language\FunctionalCode
public function testLanguageConfigurationElement() : void {
$this->drupalGet('language-tests/language_configuration_element');
$edit['lang_configuration[langcode]'] = 'current_interface';
$edit['lang_configuration[language_alterable]'] = FALSE;
$this->submitForm($edit, 'Save');
$lang_conf = ContentLanguageSettings::loadByEntityTypeBundle('entity_test', 'some_bundle');
// Check that the settings have been saved.
$this->assertEquals('current_interface', $lang_conf->getDefaultLangcode());
$this->assertFalse($lang_conf->isLanguageAlterable());
$this->drupalGet('language-tests/language_configuration_element');
$this->assertTrue($this->assertSession()
->optionExists('edit-lang-configuration-langcode', 'current_interface')
->isSelected());
$this->assertSession()
->checkboxNotChecked('edit-lang-configuration-language-alterable');
// Reload the page and save again.
$this->drupalGet('language-tests/language_configuration_element');
$edit['lang_configuration[langcode]'] = 'authors_default';
$edit['lang_configuration[language_alterable]'] = TRUE;
$this->submitForm($edit, 'Save');
$lang_conf = ContentLanguageSettings::loadByEntityTypeBundle('entity_test', 'some_bundle');
// Check that the settings have been saved.
$this->assertEquals('authors_default', $lang_conf->getDefaultLangcode());
$this->assertTrue($lang_conf->isLanguageAlterable());
$this->drupalGet('language-tests/language_configuration_element');
$this->assertTrue($this->assertSession()
->optionExists('edit-lang-configuration-langcode', 'authors_default')
->isSelected());
$this->assertSession()
->checkboxChecked('edit-lang-configuration-language-alterable');
// Test if content type settings have been saved.
$edit = [
'name' => 'Page',
'type' => 'page',
'language_configuration[langcode]' => 'authors_default',
'language_configuration[language_alterable]' => TRUE,
];
$this->drupalGet('admin/structure/types/add');
$this->submitForm($edit, 'Save and manage fields');
// Make sure the settings are saved when creating the content type.
$this->drupalGet('admin/structure/types/manage/page');
$this->assertTrue($this->assertSession()
->optionExists('edit-language-configuration-langcode', 'authors_default')
->isSelected());
$this->assertSession()
->checkboxChecked('edit-language-configuration-language-alterable');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.