public function SelectOrOtherWidgetBaseTest::testSettingsForm in Select (or other) 8.3
Tests functionality of SelectOrOtherWidgetBase::settingsForm
File
- tests/
src/ Unit/ SelectOrOtherWidgetBaseTest.php, line 84
Class
- SelectOrOtherWidgetBaseTest
- Tests the form element implementation.
Namespace
Drupal\tests\select_or_other\UnitCode
public function testSettingsForm() {
$dummy_form = [];
$dummy_state = new FormState();
$expected_keys = [
'#title',
'#type',
'#options',
'#default_value',
];
$element_key = 'select_element_type';
$options = [
'select_or_other_select',
'select_or_other_buttons',
];
/** @var SelectOrOtherWidgetBase $mock */
$mock = $this->widgetBaseMock;
foreach ($options as $option) {
$mock
->setSetting($element_key, $option);
$form = $mock
->settingsForm($dummy_form, $dummy_state);
$this
->assertArrayEquals($expected_keys, array_keys($form[$element_key]), 'Settings form has the expected keys');
$this
->assertArrayEquals($options, array_keys($form[$element_key]['#options']), 'Settings form has the expected options.');
$this
->assertEquals($option, $form[$element_key]['#default_value'], 'default value is correct.');
}
}