You are here

public function ChoiceValidatorTest::testInvalidChoiceEmptyChoices in Zircon Profile 8.0

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

File

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

Class

ChoiceValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testInvalidChoiceEmptyChoices() {
  $constraint = new Choice(array(
    // May happen when the choices are provided dynamically, e.g. from
    // the DB or the model
    'choices' => array(),
    'message' => 'myMessage',
  ));
  $this->validator
    ->validate('baz', $constraint);
  $this
    ->buildViolation('myMessage')
    ->setParameter('{{ value }}', '"baz"')
    ->setCode(Choice::NO_SUCH_CHOICE_ERROR)
    ->assertRaised();
}