function AtLeastOneOfConstraintValidatorTest::dataProvider

Data provider for testValidation().

File

core/tests/Drupal/KernelTests/Core/Validation/AtLeastOneOfConstraintValidatorTest.php, line 71

Class

AtLeastOneOfConstraintValidatorTest
Tests AtLeastOneOf validation constraint with both valid and invalid values.

Namespace

Drupal\KernelTests\Core\Validation

Code

public static function dataProvider() : array {
  return [
    'It should fail on a failing sibling validator' => [
      'integer',
      1,
      [
        [
          'Range' => [
            'min' => 100,
          ],
        ],
        [
          'NotNull' => [],
        ],
      ],
      [
        'This value should be blank.',
      ],
      [
        'Blank' => [],
      ],
    ],
    'it should not fail if first validator fails' => [
      'integer',
      250,
      [
        [
          'AllowedValues' => [
            500,
          ],
        ],
        [
          'Range' => [
            'min' => 100,
          ],
        ],
      ],
      [],
    ],
    'it should not fail if second validator fails' => [
      'integer',
      250,
      [
        [
          'Range' => [
            'min' => 100,
          ],
        ],
        [
          'AllowedValues' => [
            500,
          ],
        ],
      ],
      [],
    ],
    'it should show multiple validation errors if none validate' => [
      'string',
      'Green',
      [
        [
          'AllowedValues' => [
            'test',
          ],
        ],
        [
          'Blank' => [],
        ],
      ],
      [
        'This value should satisfy at least one of the following constraints: [1] The value you selected is not a valid choice. [2] This value should be blank.',
      ],
    ],
  ];
}

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