public function LanguageSelectElementTest::testHiddenLanguageSelectElement in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php \Drupal\Tests\system\Functional\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/ tests/ src/ Functional/ Form/ LanguageSelectElementTest.php, line 76
Class
- LanguageSelectElementTest
- Tests that the language select form element prints and submits the right options.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testHiddenLanguageSelectElement() {
// Disable the language module, so that the language select field will not
// be rendered.
$this->container
->get('module_installer')
->uninstall([
'language',
]);
$this
->drupalGet('form-test/language_select');
// Check that the language fields were rendered on the page.
$ids = [
'edit-languages-all',
'edit-languages-configurable',
'edit-languages-locked',
'edit-languages-config-and-locked',
];
foreach ($ids as $id) {
$this
->assertSession()
->fieldNotExists($id);
}
// Check that the submitted values were the default values of the language
// field elements.
$edit = [];
$this
->submitForm($edit, 'Submit');
$values = Json::decode($this
->getSession()
->getPage()
->getContent());
$this
->assertEquals('xx', $values['languages_all']);
$this
->assertEquals('en', $values['languages_configurable']);
$this
->assertEquals(LanguageInterface::LANGCODE_NOT_SPECIFIED, $values['languages_locked']);
$this
->assertEquals('dummy_value', $values['languages_config_and_locked']);
$this
->assertEquals('opt2', $values['language_custom_options']);
}