protected function RangeWidgetUiTest::assertTextFieldsWidgetUi in Range 8
Asserts that widget settings UI works as expected.
1 call to RangeWidgetUiTest::assertTextFieldsWidgetUi()
- RangeWidgetUiTest::testTextFieldsWidgetUi in tests/
src/ Functional/ Widget/ RangeWidgetUiTest.php - Tests widget UI.
File
- tests/
src/ Functional/ Widget/ RangeWidgetUiTest.php, line 75
Class
- RangeWidgetUiTest
- Tests the text fields field widget UI.
Namespace
Drupal\Tests\range\Functional\WidgetCode
protected function assertTextFieldsWidgetUi() {
$this
->drupalGet('entity_test/structure/entity_test/form-display');
// Enable Default formatter.
$edit = [
"fields[{$this->fieldName}][parent]" => 'content',
"fields[{$this->fieldName}][region]" => 'content',
"fields[{$this->fieldName}][type]" => 'range',
];
$this
->submitForm($edit, 'Save');
// Ensure that summary is correct.
$this
->assertSession()
->pageTextContains('FROM form element label: From');
$this
->assertSession()
->pageTextContains('TO form element label: to');
$this
->assertSession()
->pageTextContains('No FROM placeholder');
$this
->assertSession()
->pageTextContains('No TO placeholder');
// Go to widget settings form.
$this
->submitForm([], $this->fieldName . '_settings_edit');
// Ensure that form displays correct set of fields.
$this
->assertSession()
->fieldValueEquals('FROM form element label', 'From');
$this
->assertSession()
->fieldValueEquals('TO form element label', 'to');
$this
->assertSession()
->fieldValueEquals('FROM placeholder', '');
$this
->assertSession()
->fieldValueEquals('TO placeholder', '');
// Update widget settings.
$widget_settings = $this
->getWidgetSettings();
$edit = [
"fields[{$this->fieldName}][settings_edit_form][settings][label][from]" => $widget_settings['label']['from'],
"fields[{$this->fieldName}][settings_edit_form][settings][label][to]" => $widget_settings['label']['to'],
"fields[{$this->fieldName}][settings_edit_form][settings][placeholder][from]" => $widget_settings['placeholder']['from'],
"fields[{$this->fieldName}][settings_edit_form][settings][placeholder][to]" => $widget_settings['placeholder']['to'],
];
$this
->submitForm($edit, 'Update');
// Ensure that summary is correct.
$this
->assertSession()
->pageTextContains('FROM form element label: ' . $widget_settings['label']['from']);
$this
->assertSession()
->pageTextContains('TO form element label: ' . $widget_settings['label']['to']);
$this
->assertSession()
->pageTextContains('FROM placeholder: ' . $widget_settings['placeholder']['from']);
$this
->assertSession()
->pageTextContains('TO placeholder: ' . $widget_settings['placeholder']['to']);
// Go to widget settings form.
$this
->submitForm([], $this->fieldName . '_settings_edit');
// Ensure that form displays correct set of fields.
$this
->assertSession()
->fieldValueEquals('FROM form element label', $widget_settings['label']['from']);
$this
->assertSession()
->fieldValueEquals('TO form element label', $widget_settings['label']['to']);
$this
->assertSession()
->fieldValueEquals('FROM placeholder', $widget_settings['placeholder']['from']);
$this
->assertSession()
->fieldValueEquals('TO placeholder', $widget_settings['placeholder']['to']);
}