public function WordsFieldValidationRuleTest::testCountWords in Field Validation 8
Tests WordFieldValidationRule.
File
- tests/
src/ Kernel/ Plugin/ FieldValidationRule/ WordsFieldValidationRuleTest.php, line 85
Class
- WordsFieldValidationRuleTest
- Tests WordsFieldValidationRule.
Namespace
Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRuleCode
public function testCountWords() {
$this
->assertConstraintFail($this->entity, self::FIELD_NAME, 'one', $this->ruleSet);
$this
->assertConstraintFail($this->entity, self::FIELD_NAME, 'one two three four five six seven eight nine ten eleven', $this->ruleSet);
$this
->assertConstraintPass($this->entity, self::FIELD_NAME, 'one two three four five six');
$this
->updateSettings([
'min' => '1',
'max' => '2',
], self::RULE_ID, self::RULE_TITLE, $this->ruleSet, self::FIELD_NAME);
$this
->assertConstraintFail($this->entity, self::FIELD_NAME, 'one two three four five six', $this->ruleSet);
$this
->assertConstraintPass($this->entity, self::FIELD_NAME, 'one');
}