You are here

public function LengthValidatorTest::testOneCharset in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Tests/Constraints/LengthValidatorTest.php \Symfony\Component\Validator\Tests\Constraints\LengthValidatorTest::testOneCharset()

@dataProvider getOneCharset

File

vendor/symfony/validator/Tests/Constraints/LengthValidatorTest.php, line 226

Class

LengthValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testOneCharset($value, $charset, $isValid) {
  $constraint = new Length(array(
    'min' => 1,
    'max' => 1,
    'charset' => $charset,
    'charsetMessage' => 'myMessage',
  ));
  $this->validator
    ->validate($value, $constraint);
  if ($isValid) {
    $this
      ->assertNoViolation();
  }
  else {
    $this
      ->buildViolation('myMessage')
      ->setParameter('{{ value }}', '"' . $value . '"')
      ->setParameter('{{ charset }}', $charset)
      ->setInvalidValue($value)
      ->assertRaised();
  }
}