You are here

public function CountryConstraintValidatorTest::providerTestValidate in Address 8

Data provider for ::testValidate().

File

tests/src/Unit/Plugin/Validation/Constraint/CountryConstraintValidatorTest.php, line 70

Class

CountryConstraintValidatorTest
@coversDefaultClass \Drupal\address\Plugin\Validation\Constraint\CountryConstraintValidator @group address

Namespace

Drupal\Tests\address\Unit\Plugin\Validation\Constraint

Code

public function providerTestValidate() {

  // Data provides run before setUp, so $this->constraint is not available.
  $constraint = new CountryConstraint();
  $cases = [];

  // Case 1: Empty values.
  $cases[] = [
    NULL,
    FALSE,
  ];
  $cases[] = [
    '',
    FALSE,
  ];

  // Case 2: Valid country.
  $cases[] = [
    'FR',
    FALSE,
  ];

  // Case 3: Invalid country.
  $cases[] = [
    'InvalidValue',
    $constraint->invalidMessage,
  ];

  // Case 4: Valid, but unavailable country.
  $cases[] = [
    'RS',
    $constraint->notAvailableMessage,
  ];
  return $cases;
}