You are here

public function CallbackValidatorTest::testClosure in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php, line 102

Class

CallbackValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testClosure() {
  $object = new CallbackValidatorTest_Object();
  $constraint = new Callback(function ($object, ExecutionContextInterface $context) {
    $context
      ->addViolation('My message', array(
      '{{ value }}' => 'foobar',
    ));
    return false;
  });
  $this->validator
    ->validate($object, $constraint);
  $this
    ->buildViolation('My message')
    ->setParameter('{{ value }}', 'foobar')
    ->assertRaised();
}