public function TriggeringElementProgrammedTest::testLimitValidationErrors in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php \Drupal\KernelTests\Core\Form\TriggeringElementProgrammedTest::testLimitValidationErrors()
Tests that #limit_validation_errors of the only submit button takes effect.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Form/ TriggeringElementProgrammedTest.php, line 69
Class
- TriggeringElementProgrammedTest
- Tests detection of triggering_element for programmed form submissions.
Namespace
Drupal\KernelTests\Core\FormCode
public function testLimitValidationErrors() {
// Programmatically submit the form.
$form_state = new FormState();
$form_state
->setValue('section', 'one');
$form_builder = $this->container
->get('form_builder');
$form_builder
->submitForm($this, $form_state);
// Verify that only the specified section was validated.
$errors = $form_state
->getErrors();
$this
->assertTrue(isset($errors['one']), "Section 'one' was validated.");
$this
->assertFalse(isset($errors['two']), "Section 'two' was not validated.");
// Verify that there are only values for the specified section.
$this
->assertTrue($form_state
->hasValue('one'), "Values for section 'one' found.");
$this
->assertFalse($form_state
->hasValue('two'), "Values for section 'two' not found.");
}