function FormStateTest::testFormErrorsDuringSubmission
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Form/FormStateTest.php \Drupal\Tests\Core\Form\FormStateTest::testFormErrorsDuringSubmission()
- 10 core/tests/Drupal/Tests/Core/Form/FormStateTest.php \Drupal\Tests\Core\Form\FormStateTest::testFormErrorsDuringSubmission()
- 11.x core/tests/Drupal/Tests/Core/Form/FormStateTest.php \Drupal\Tests\Core\Form\FormStateTest::testFormErrorsDuringSubmission()
Tests that form errors during submission throw an exception.
@covers ::setErrorByName
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ FormStateTest.php, line 136
Class
- FormStateTest
- @coversDefaultClass \Drupal\Core\Form\FormState
Namespace
Drupal\Tests\Core\FormCode
public function testFormErrorsDuringSubmission() {
$form_state = new FormState();
$form_state->setValidationComplete();
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Form errors cannot be set after form validation has finished.');
$form_state->setErrorByName('test', 'message');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.