public function MultipleSelectsWidgetUiTest::testWidgetSettings in Multiple Selects 8
Test the field widget settings.
File
- tests/
src/ Functional/ MultipleSelectsWidgetUiTest.php, line 263
Class
- MultipleSelectsWidgetUiTest
- Tests the multiple select widget.
Namespace
Drupal\Tests\multiple_selects\FunctionalCode
public function testWidgetSettings() {
$this
->drupalGet('admin/structure/types/manage/page/form-display');
$this
->getSession()
->getPage()
->pressButton('field_tags_settings_edit');
// Select 2 is not enabled, so it shouldn't be in the list of available
// options.
$this
->assertSession()
->optionExists('fields[field_tags][settings_edit_form][settings][element_type]', 'select');
$this
->assertSession()
->optionNotExists('fields[field_tags][settings_edit_form][settings][element_type]', 'select2');
$this->moduleInstaller
->install([
'select2',
]);
$this
->drupalGet('admin/structure/types/manage/page/form-display');
$this
->getSession()
->getPage()
->pressButton('field_tags_settings_edit');
// Select 2 is now enabled, so it should be in the list of available
// options.
$this
->assertSession()
->optionExists('fields[field_tags][settings_edit_form][settings][element_type]', 'select');
$this
->assertSession()
->optionExists('fields[field_tags][settings_edit_form][settings][element_type]', 'select2');
// Save the element and check if it's correctly saved in config.
$this
->getSession()
->getPage()
->selectFieldOption('fields[field_tags][settings_edit_form][settings][element_type]', 'select2');
$this
->getSession()
->getPage()
->pressButton('field_tags_plugin_settings_update');
$this
->getSession()
->getPage()
->pressButton('Save');
$entity_form_display = EntityFormDisplay::load('node.page.default');
$this
->assertEquals('select2', $entity_form_display
->getComponent('field_tags')['settings']['element_type']);
}