protected function EmailFieldValidationRuleTest::setUp in Field Validation 8
Overrides FieldValidationRuleBase::setUp
File
- tests/
src/ Kernel/ Plugin/ FieldValidationRule/ EmailFieldValidationRuleTest.php, line 36
Class
- EmailFieldValidationRuleTest
- Tests EmailFieldValidationRule.
Namespace
Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRuleCode
protected function setUp() {
parent::setUp();
$this
->setupTestArticle(self::FIELD_NAME);
$this->ruleSet = $this->ruleSetStorage
->create([
'name' => 'email_test',
'entity_type' => 'node',
'bundle' => 'article',
]);
$this->ruleSet
->addFieldValidationRule([
'id' => 'email_field_validation_rule',
'title' => 'validation rule email',
'weight' => 1,
'field_name' => self::FIELD_NAME,
'column' => 'value',
'error_message' => 'Email is not valid',
]);
$this->ruleSet
->save();
$this->entity = $this->nodeStorage
->create([
'type' => 'article',
'title' => 'test',
'field_email_text' => 'invalid.com',
]);
$this->entity
->get(self::FIELD_NAME)
->getFieldDefinition()
->addConstraint('FieldValidationConstraint', [
'ruleset_name' => $this->ruleSet
->getName(),
]);
}