protected function FieldValidationRuleBase::assertConstraintFail in Field Validation 8
Helper method for failed assertions.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: EntityInterface to validate.
string $fieldName: Field to validate.
string $value: Value to validate.
\Drupal\field_validation\Entity\FieldValidationRuleSet $ruleSet: Ruleset to check constraints.
14 calls to FieldValidationRuleBase::assertConstraintFail()
- BlackListFieldValidationRuleTest::testBlacklistRule in tests/
src/ Kernel/ Plugin/ FieldValidationRule/ BlackListFieldValidationRuleTest.php - Tests BlacklistFieldValidationRule.
- DateRangeFieldValidationRuleTest::testInvalidDateRangeRule in tests/
src/ Kernel/ Plugin/ FieldValidationRule/ DateRangeFieldValidationRuleTest.php - Tests invalid date inputs.
- EmailFieldValidationRuleTest::testEmailRule in tests/
src/ Kernel/ Plugin/ FieldValidationRule/ EmailFieldValidationRuleTest.php - Test EmailFieldValidationRule.
- FieldValidationRuleBase::emptyAndMalformed in tests/
src/ Kernel/ Plugin/ FieldValidationRule/ FieldValidationRuleBase.php - Helper method for empty and malformed inputs which must fail.
- IntegerFieldValidationTest::testInteger in tests/
src/ Kernel/ Plugin/ FieldValidationRule/ IntegerFieldValidationTest.php - Test IntegerFieldValidationRule.
File
- tests/
src/ Kernel/ Plugin/ FieldValidationRule/ FieldValidationRuleBase.php, line 157
Class
- FieldValidationRuleBase
- FieldValidationRuleBase class.
Namespace
Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRuleCode
protected function assertConstraintFail(EntityInterface $entity, string $fieldName, string $value, FieldValidationRuleSet $ruleSet) {
$entity
->get($fieldName)->value = $value;
$violations = $entity
->validate();
$this
->assertCount(1, $violations);
$this
->assertInstanceOf(FieldValidationConstraint::class, $violations[0]
->getConstraint());
$this
->assertEquals($ruleSet
->getName(), $violations[0]
->getConstraint()->ruleset_name);
}