function ValidSequenceKeysValidatorTest::dataProvider

Data provider for test.

File

core/tests/Drupal/KernelTests/Core/Validation/ValidSequenceKeysValidatorTest.php, line 85

Class

ValidSequenceKeysValidatorTest
Tests ValidSequenceKeys 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' => [
      'value' => [
        'system' => 1,
        'node' => 1,
      ],
      'constraints' => [
        'ExtensionName' => [],
        'ExtensionAvailable' => [
          'type' => 'module',
        ],
      ],
      'expected_violations' => [
        'This value should be blank.',
      ],
      'extra_constraints' => [
        'Blank' => [],
      ],
    ],
    'it should fail if first validator fails' => [
      'value' => [
        'system1' => 1,
        'stark' => 1,
      ],
      'constraints' => [
        'ExtensionAvailable' => [
          'type' => 'theme',
        ],
        'ExtensionName' => [],
        'Blank' => [],
      ],
      'expected_violations' => [
        'Theme \'system1\' is not available.',
        'This value should be blank.',
        'This value should be blank.',
        'The keys of the sequence do not match the given constraints.',
      ],
    ],
    'it should fail if second validator fails' => [
      'value' => [
        'red' => 0,
      ],
      'constraints' => [
        'ExtensionName' => [],
        'ExtensionAvailable' => [
          'type' => 'module',
        ],
        'Blank' => [],
      ],
      'expected_violations' => [
        'Module \'red\' is not available.',
        'This value should be blank.',
        'The keys of the sequence do not match the given constraints.',
      ],
    ],
  ];
}

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