function RecursiveContextualValidatorTest::testBasicValidateWithMultipleConstraints
Tests basic validate with multiple constraints.
@legacy-covers ::validate
File
-
core/
tests/ Drupal/ Tests/ Core/ TypedData/ RecursiveContextualValidatorTest.php, line 155
Class
- RecursiveContextualValidatorTest
- Tests Drupal\Core\TypedData\Validation\RecursiveContextualValidator.
Namespace
Drupal\Tests\Core\TypedDataCode
public function testBasicValidateWithMultipleConstraints() : void {
$options = [
'callback' => function ($value, ExecutionContextInterface $context) {
$context->addViolation('test violation');
},
];
$typed_data = $this->typedDataManager
->create(DataDefinition::create('string')->addConstraint('Callback', $options)
->addConstraint('NotNull'));
$violations = $this->recursiveValidator
->validate($typed_data);
$this->assertCount(2, $violations);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.