function MultipleValueWidgetTest::testFieldMultipleValueWidgetAddMoreNoValidation
Same name in other branches
- 10 core/modules/field/tests/src/FunctionalJavascript/MultipleValueWidgetTest.php \Drupal\Tests\field\FunctionalJavascript\MultipleValueWidgetTest::testFieldMultipleValueWidgetAddMoreNoValidation()
Tests that no validation occurs on field on "Add more" click.
File
-
core/
modules/ field/ tests/ src/ FunctionalJavascript/ MultipleValueWidgetTest.php, line 175
Class
- MultipleValueWidgetTest
- Tests widget form for a multiple value field.
Namespace
Drupal\Tests\field\FunctionalJavascriptCode
public function testFieldMultipleValueWidgetAddMoreNoValidation() : void {
// Set unlimited field to be required.
$field_name = 'field_unlimited';
$field = FieldConfig::loadByName('entity_test', 'entity_test', $field_name);
$field->setRequired(TRUE);
$field->save();
$this->drupalGet('entity_test/add');
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
// Add another item with the first item being empty, even though the field
// is required.
$add_more_button = $page->findButton('field_unlimited_add_more');
$add_more_button->click();
$field_1 = $assert_session->waitForField('field_unlimited[1][value]');
$this->assertNotEmpty($field_1, 'Successfully added another item.');
// Confirm the new item has focus.
$this->assertHasFocusByAttribute('name', 'field_unlimited[1][value]');
// The first item should not be in error state.
$assert_session->elementNotExists('css', 'input[name="field_unlimited[0][value]"].error');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.