You are here

public function PhoneFieldValidationRuleTest::testPhoneFieldInvalid in Field Validation 8

Tests invalid phone numbers.

@dataProvider phoneNumbersProviderInvalid Data provider with invalid phone numbers.

Parameters

string $country: Country to test.

string $value: Value to test.

Throws

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Kernel/Plugin/FieldValidationRule/PhoneFieldValidationRuleTest.php, line 120

Class

PhoneFieldValidationRuleTest
Tests PhoneFieldValidationRule.

Namespace

Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRule

Code

public function testPhoneFieldInvalid(string $country, string $value) {
  $data = [
    'country' => $country,
  ];
  $this->ruleSet = $this
    ->updateSettings($data, self::RULE_ID, self::RULE_TITLE, $this->ruleSet, self::FIELD_NAME);
  $this
    ->assertConstraintFail($this->entity, self::FIELD_NAME, $value, $this->ruleSet);
}