You are here

public function PatternDataDefinitionTest::testValidation in UI Patterns 8

Test plugin validation.

@dataProvider validationProvider

File

tests/src/Kernel/TypedData/PatternDataDefinitionTest.php, line 20

Class

PatternDataDefinitionTest
@coversDefaultClass \Drupal\ui_patterns\TypedData\PatternDataDefinition

Namespace

Drupal\Tests\ui_patterns\Kernel\TypedData

Code

public function testValidation($data, $expected) {
  $definition = PatternDataDefinition::create();
  $violations = \Drupal::typedDataManager()
    ->create($definition, $data)
    ->validate();
  $actual = [];
  foreach ($violations as $violation) {
    $actual[] = $violation
      ->getPropertyPath() . ': ' . $violation
      ->getMessage();
  }
  $this
    ->assertEquals($expected, $actual);
}