function FormValidatorTest::providerTestHandleErrorsWithLimitedValidation

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php \Drupal\Tests\Core\Form\FormValidatorTest::providerTestHandleErrorsWithLimitedValidation()
  2. 8.9.x core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php \Drupal\Tests\Core\Form\FormValidatorTest::providerTestHandleErrorsWithLimitedValidation()
  3. 10 core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php \Drupal\Tests\Core\Form\FormValidatorTest::providerTestHandleErrorsWithLimitedValidation()

File

core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php, line 186

Class

FormValidatorTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormValidator.php/class/FormValidator/11.x" title="Provides validation of form submissions." class="local">\Drupal\Core\Form\FormValidator</a> @group Form

Namespace

Drupal\Tests\Core\Form

Code

public static function providerTestHandleErrorsWithLimitedValidation() {
    return [
        // Test with a non-existent section.
[
            [
                [
                    'test1',
                ],
                [
                    'test3',
                ],
            ],
            [],
            [
                'test1' => 'foo',
                'test2' => 'bar',
            ],
            [
                'test1' => 'foo',
            ],
        ],
        // Test with buttons in a non-validated section.
[
            [
                [
                    'test1',
                ],
            ],
            [
                '#is_button' => TRUE,
                '#value' => 'baz',
                '#name' => 'op',
                '#parents' => [
                    'submit',
                ],
            ],
            [
                'test1' => 'foo',
                'test2' => 'bar',
                'op' => 'baz',
                'submit' => 'baz',
            ],
            [
                'test1' => 'foo',
                'submit' => 'baz',
                'op' => 'baz',
            ],
        ],
        // Test with a matching button #value and $form_state value.
[
            [
                [
                    'submit',
                ],
            ],
            [
                '#is_button' => TRUE,
                '#value' => 'baz',
                '#name' => 'op',
                '#parents' => [
                    'submit',
                ],
            ],
            [
                'test1' => 'foo',
                'test2' => 'bar',
                'op' => 'baz',
                'submit' => 'baz',
            ],
            [
                'submit' => 'baz',
                'op' => 'baz',
            ],
        ],
        // Test with a mismatched button #value and $form_state value.
[
            [
                [
                    'submit',
                ],
            ],
            [
                '#is_button' => TRUE,
                '#value' => 'bar',
                '#name' => 'op',
                '#parents' => [
                    'submit',
                ],
            ],
            [
                'test1' => 'foo',
                'test2' => 'bar',
                'op' => 'baz',
                'submit' => 'baz',
            ],
            [
                'submit' => 'baz',
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.