public function RegexFieldValidationRuleTest::testRegexPattern in Field Validation 8
Tests WordFieldValidationRule.
File
- tests/
src/ Kernel/ Plugin/ FieldValidationRule/ RegexFieldValidationRuleTest.php, line 84
Class
- RegexFieldValidationRuleTest
- Tests RegexFieldValidationRule.
Namespace
Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRuleCode
public function testRegexPattern() {
$this
->updateSettings([
'setting' => '/[A-Za-z]/',
], self::RULE_ID, self::RULE_TITLE, $this->ruleSet, self::FIELD_NAME);
$this
->assertConstraintPass($this->entity, self::FIELD_NAME, 'abcdefg');
$this
->assertConstraintFail($this->entity, self::FIELD_NAME, '1234', $this->ruleSet);
$this
->updateSettings([
'setting' => '/[1-9]/',
], self::RULE_ID, self::RULE_TITLE, $this->ruleSet, self::FIELD_NAME);
$this
->assertConstraintPass($this->entity, self::FIELD_NAME, '1234');
$this
->assertConstraintFail($this->entity, self::FIELD_NAME, 'abcdefg', $this->ruleSet);
}