You are here

public function LengthFieldValidationRuleTest::testLengthField in Field Validation 8

Test LengthFieldValidationRule.

File

tests/src/Kernel/Plugin/FieldValidationRule/LengthFieldValidationRuleTest.php, line 98

Class

LengthFieldValidationRuleTest
Tests LengthFieldValidationRule.

Namespace

Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRule

Code

public function testLengthField() {
  $string = 'abcabcabcabc';
  $this
    ->assertConstraintPass($this->entity, self::FIELD_NAME, $string);
  $string = '1234567891011';
  $this
    ->assertConstraintPass($this->entity, self::FIELD_NAME, $string);
  $string = '!"£$%^&*()_+{}{}\'"';
  $this
    ->assertConstraintPass($this->entity, self::FIELD_NAME, $string);
  $string = '!"£$%^&*()_+{}{}\'"<>?~#\\|1234567890';
  $this
    ->assertConstraintFail($this->entity, self::FIELD_NAME, $string, $this->ruleSet);
  $string = '12456';
  $this
    ->assertConstraintFail($this->entity, self::FIELD_NAME, $string, $this->ruleSet);
  $string = 'ABCDEF';
  $this
    ->assertConstraintFail($this->entity, self::FIELD_NAME, $string, $this->ruleSet);
}