You are here

public function FormValidatorTest::providerTestPerformRequiredValidation 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::providerTestPerformRequiredValidation()
  2. 9 core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php \Drupal\Tests\Core\Form\FormValidatorTest::providerTestPerformRequiredValidation()

File

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

Class

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

Namespace

Drupal\Tests\Core\Form

Code

public function providerTestPerformRequiredValidation() {
  return [
    [
      [
        '#type' => 'select',
        '#options' => [
          'foo' => 'Foo',
          'bar' => 'Bar',
        ],
        '#required' => TRUE,
        '#value' => 'baz',
        '#empty_value' => 'baz',
        '#multiple' => FALSE,
      ],
      'Test field is required.',
      FALSE,
    ],
    [
      [
        '#type' => 'select',
        '#options' => [
          'foo' => 'Foo',
          'bar' => 'Bar',
        ],
        '#value' => 'baz',
        '#multiple' => FALSE,
      ],
      'An illegal choice has been detected. Please contact the site administrator.',
      TRUE,
    ],
    [
      [
        '#type' => 'checkboxes',
        '#options' => [
          'foo' => 'Foo',
          'bar' => 'Bar',
        ],
        '#value' => [
          'baz',
        ],
        '#multiple' => TRUE,
      ],
      'An illegal choice has been detected. Please contact the site administrator.',
      TRUE,
    ],
    [
      [
        '#type' => 'select',
        '#options' => [
          'foo' => 'Foo',
          'bar' => 'Bar',
        ],
        '#value' => [
          'baz',
        ],
        '#multiple' => TRUE,
      ],
      'An illegal choice has been detected. Please contact the site administrator.',
      TRUE,
    ],
    [
      [
        '#type' => 'textfield',
        '#maxlength' => 7,
        '#value' => $this
          ->randomMachineName(8),
      ],
      'Test cannot be longer than <em class="placeholder">7</em> characters but is currently <em class="placeholder">8</em> characters long.',
      FALSE,
    ],
  ];
}