You are here

public function PhoneFieldValidationRuleTest::testPhoneFieldValid in Field Validation 8

Tests valid phone numbers by country.

@dataProvider phoneNumbersProviderValid Data provider with valid 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 93

Class

PhoneFieldValidationRuleTest
Tests PhoneFieldValidationRule.

Namespace

Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRule

Code

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