public function FormStateTest::testFormErrorsDuringSubmission in Drupal 8
Same name and namespace in other branches
- 9 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()
Tests that form errors during submission throw an exception.
@covers ::setErrorByName
File
- core/
tests/ Drupal/ Tests/ Core/ Form/ FormStateTest.php, line 136 - Contains \Drupal\Tests\Core\Form\FormStateTest.
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');
}