You are here

public function BlackListFieldValidationRuleTest::testBlacklistRule in Field Validation 8

Tests BlacklistFieldValidationRule.

File

tests/src/Kernel/Plugin/FieldValidationRule/BlackListFieldValidationRuleTest.php, line 96

Class

BlackListFieldValidationRuleTest
Tests BlacklistFieldValidationRule.

Namespace

Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRule

Code

public function testBlacklistRule() {
  $this
    ->assertConstraintFail($this->entity, self::FIELD_NAME, $this->blacklisted[array_rand($this->blacklisted)], $this->ruleSet);
  $this
    ->assertConstraintFail($this->entity, self::FIELD_NAME, implode(',', $this->blacklisted), $this->ruleSet);
  $this
    ->assertConstraintPass($this->entity, self::FIELD_NAME, $this->whitelisted[array_rand($this->whitelisted)]);
  $this
    ->assertConstraintPass($this->entity, self::FIELD_NAME, implode(',', $this->whitelisted));
}