public function FieldWidgetConstraintValidatorTest::testEntityLevelConstraintValidation in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php \Drupal\KernelTests\Core\Entity\FieldWidgetConstraintValidatorTest::testEntityLevelConstraintValidation()
- 10 core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php \Drupal\KernelTests\Core\Entity\FieldWidgetConstraintValidatorTest::testEntityLevelConstraintValidation()
Tests entity level constraint validation.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ FieldWidgetConstraintValidatorTest.php, line 150
Class
- FieldWidgetConstraintValidatorTest
- Tests validation constraints for FieldWidgetConstraintValidatorTest.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testEntityLevelConstraintValidation() {
$entity = EntityTestCompositeConstraint::create([
'name' => 'entity-level-violation',
]);
$entity
->save();
$errors = $this
->getErrorsForEntity($entity);
$this
->assertEquals('Entity level validation', $errors['']);
$entity->name->value = 'entity-level-violation-with-path';
$errors = $this
->getErrorsForEntity($entity);
$this
->assertEquals('Entity level validation', $errors['test][form][element']);
}