You are here

public function LengthValidatorTest::testOneCharset in Plug 7

@dataProvider getOneCharset

File

lib/Symfony/validator/Symfony/Component/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();
  }
}