function FormTest::testRequiredAttribute
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Form/FormTest.php \Drupal\Tests\system\Functional\Form\FormTest::testRequiredAttribute()
- 8.9.x core/modules/system/tests/src/Functional/Form/FormTest.php \Drupal\Tests\system\Functional\Form\FormTest::testRequiredAttribute()
- 10 core/modules/system/tests/src/Functional/Form/FormTest.php \Drupal\Tests\system\Functional\Form\FormTest::testRequiredAttribute()
Tests required attribute.
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ FormTest.php, line 891
Class
- FormTest
- Tests various form element validation mechanisms.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testRequiredAttribute() : void {
$this->drupalGet('form-test/required-attribute');
foreach ([
'textfield',
'password',
'textarea',
] as $type) {
$field = $this->assertSession()
->fieldExists("edit-{$type}");
$this->assertSame('required', $field->getAttribute('required'), "The {$type} has the proper required attribute.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.