You are here

public function ChoiceValidatorTest::testTooManyChoices in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php, line 210

Class

ChoiceValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testTooManyChoices() {
  $constraint = new Choice(array(
    'choices' => array(
      'foo',
      'bar',
      'moo',
      'maa',
    ),
    'multiple' => true,
    'max' => 2,
    'maxMessage' => 'myMessage',
  ));
  $value = array(
    'foo',
    'bar',
    'moo',
  );
  $this
    ->setValue($value);
  $this->validator
    ->validate($value, $constraint);
  $this
    ->buildViolation('myMessage')
    ->setParameter('{{ limit }}', 2)
    ->setInvalidValue($value)
    ->setPlural(2)
    ->setCode(Choice::TOO_MANY_ERROR)
    ->assertRaised();
}