function RecursiveContextualValidatorTest::testValidatePropertyValue

@covers ::validatePropertyValue

File

core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php, line 294

Class

RecursiveContextualValidatorTest
@coversDefaultClass \Drupal\Core\TypedData\Validation\RecursiveContextualValidator[[api-linebreak]] @group TypedData

Namespace

Drupal\Tests\Core\TypedData

Code

public function testValidatePropertyValue() : void {
  $typed_data = $this->buildExampleTypedDataWithProperties([
    'subkey1' => 'subvalue11',
    'subkey2' => 'subvalue22',
  ]);
  $violations = $this->recursiveValidator
    ->validatePropertyValue($typed_data, 'key_with_properties', $typed_data->get('key_with_properties'));
  $this->assertCount(3, $violations);
  $this->assertEquals('violation: 2', $violations->get(0)
    ->getMessage());
  $this->assertEquals('violation: subvalue11', $violations->get(1)
    ->getMessage());
  $this->assertEquals('violation: subvalue22', $violations->get(2)
    ->getMessage());
  $this->assertEquals('', $violations->get(0)
    ->getPropertyPath());
  $this->assertEquals('subkey1', $violations->get(1)
    ->getPropertyPath());
  $this->assertEquals('subkey2', $violations->get(2)
    ->getPropertyPath());
}

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