protected function IntegerFieldValidationTest::setUp in Field Validation 8
Overrides FieldValidationRuleBase::setUp
File
- tests/
src/ Kernel/ Plugin/ FieldValidationRule/ IntegerFieldValidationTest.php, line 50
Class
- IntegerFieldValidationTest
- Tests IntegerFieldValidationRule.
Namespace
Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRuleCode
protected function setUp() {
parent::setUp();
$this->min = -255;
$this->max = 255;
$this
->setupTestArticle(self::FIELD_NAME);
$this->ruleSet = $this->ruleSetStorage
->create([
'name' => 'integer_test_text',
'entity_type' => 'node',
'bundle' => 'article',
]);
$this->ruleSet
->addFieldValidationRule([
'id' => 'integer_field_validation_rule',
'title' => 'validation rule integer text',
'weight' => 1,
'field_name' => self::FIELD_NAME,
'column' => 'value',
'error_message' => 'Integer is not valid text field',
'data' => [
'min' => $this->min,
'max' => $this->max,
],
]);
$this->ruleSet
->save();
$this->entity = $this->nodeStorage
->create([
'type' => 'article',
'title' => 'test',
]);
$this->entity
->get(self::FIELD_NAME)
->getFieldDefinition()
->addConstraint('FieldValidationConstraint', [
'ruleset_name' => $this->ruleSet
->getName(),
]);
}