public function RecursiveContextualValidatorTest::testPropertiesValidateWithMultipleLevels in Drupal 8
Same name and namespace in other branches
- 9 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 164 - Contains \Drupal\Tests\Core\TypedData\RecursiveContextualValidatorTest.
Class
- RecursiveContextualValidatorTest
- @coversDefaultClass \Drupal\Core\TypedData\Validation\RecursiveContextualValidator @group typedData
Namespace
Drupal\Tests\Core\TypedDataCode
public function testPropertiesValidateWithMultipleLevels() {
$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());
}