You are here

public function ChoiceValidatorTest::testTooManyChoices in Zircon Profile 8

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

File

vendor/symfony/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();
}