You are here

public function ExpressionValidatorTest::testFailingExpressionAtObjectLevel in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php, line 74

Class

ExpressionValidatorTest

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

public function testFailingExpressionAtObjectLevel() {
  $constraint = new Expression(array(
    'expression' => 'this.data == 1',
    'message' => 'myMessage',
  ));
  $object = new Entity();
  $object->data = '2';
  $this
    ->setObject($object);
  $this->validator
    ->validate($object, $constraint);
  $this
    ->buildViolation('myMessage')
    ->setParameter('{{ value }}', 'object')
    ->assertRaised();
}