You are here

public function ChoiceValidatorTest::testInvalidChoice 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::testInvalidChoice()

File

vendor/symfony/validator/Tests/Constraints/ChoiceValidatorTest.php, line 138

Class

ChoiceValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testInvalidChoice() {
  $constraint = new Choice(array(
    'choices' => array(
      'foo',
      'bar',
    ),
    'message' => 'myMessage',
  ));
  $this->validator
    ->validate('baz', $constraint);
  $this
    ->buildViolation('myMessage')
    ->setParameter('{{ value }}', '"baz"')
    ->setCode(Choice::NO_SUCH_CHOICE_ERROR)
    ->assertRaised();
}