function RecursiveContextualValidatorTest::testPropertiesValidateWithMultipleLevels
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\Tests\Core\TypedData\RecursiveContextualValidatorTest::testPropertiesValidateWithMultipleLevels()
- 8.9.x core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\Tests\Core\TypedData\RecursiveContextualValidatorTest::testPropertiesValidateWithMultipleLevels()
- 10 core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\Tests\Core\TypedData\RecursiveContextualValidatorTest::testPropertiesValidateWithMultipleLevels()
@covers ::validate
File
-
core/
tests/ Drupal/ Tests/ Core/ TypedData/ RecursiveContextualValidatorTest.php, line 162
Class
- RecursiveContextualValidatorTest
- @coversDefaultClass \Drupal\Core\TypedData\Validation\RecursiveContextualValidator @group TypedData
Namespace
Drupal\Tests\Core\TypedDataCode
public function testPropertiesValidateWithMultipleLevels() : void {
$typed_data = $this->buildExampleTypedDataWithProperties();
$violations = $this->recursiveValidator
->validate($typed_data);
$this->assertCount(6, $violations);
$this->assertEquals('violation: 3', $violations->get(0)
->getMessage());
$this->assertEquals('violation: value1', $violations->get(1)
->getMessage());
$this->assertEquals('violation: value2', $violations->get(2)
->getMessage());
$this->assertEquals('violation: 2', $violations->get(3)
->getMessage());
$this->assertEquals('violation: subvalue1', $violations->get(4)
->getMessage());
$this->assertEquals('violation: subvalue2', $violations->get(5)
->getMessage());
$this->assertEquals('', $violations->get(0)
->getPropertyPath());
$this->assertEquals('key1', $violations->get(1)
->getPropertyPath());
$this->assertEquals('key2', $violations->get(2)
->getPropertyPath());
$this->assertEquals('key_with_properties', $violations->get(3)
->getPropertyPath());
$this->assertEquals('key_with_properties.subkey1', $violations->get(4)
->getPropertyPath());
$this->assertEquals('key_with_properties.subkey2', $violations->get(5)
->getPropertyPath());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.