public function FormStateTest::testSetErrorByName in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Form/FormStateTest.php \Drupal\Tests\Core\Form\FormStateTest::testSetErrorByName()
@covers ::setErrorByName
@dataProvider providerTestSetErrorByName
File
- core/
tests/ Drupal/ Tests/ Core/ Form/ FormStateTest.php, line 106 - Contains \Drupal\Tests\Core\Form\FormStateTest.
Class
- FormStateTest
- @coversDefaultClass \Drupal\Core\Form\FormState
Namespace
Drupal\Tests\Core\FormCode
public function testSetErrorByName($limit_validation_errors, $expected_errors) {
$form_state = new FormState();
$form_state
->setLimitValidationErrors($limit_validation_errors);
$form_state
->clearErrors();
$form_state
->setErrorByName('test', 'Fail 1');
$form_state
->setErrorByName('test', 'Fail 2');
$form_state
->setErrorByName('options');
$this
->assertSame(!empty($expected_errors), $form_state::hasAnyErrors());
$this
->assertSame($expected_errors, $form_state
->getErrors());
}