You are here

public function FormValidatorTest::providerTestHandleErrorsWithLimitedValidation in Drupal 10

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

File

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

Class

FormValidatorTest
@coversDefaultClass \Drupal\Core\Form\FormValidator @group Form

Namespace

Drupal\Tests\Core\Form

Code

public 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',
      ],
    ],
  ];
}