You are here

protected function AbstractConstraintValidatorTest::setObject in Plug 7

3 calls to AbstractConstraintValidatorTest::setObject()
ChoiceValidatorTest::testValidChoiceCallbackContextMethod in lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php
ExpressionValidatorTest::testFailingExpressionAtObjectLevel in lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php
ExpressionValidatorTest::testSucceedingExpressionAtObjectLevel in lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php, line 211

Class

AbstractConstraintValidatorTest
@since 2.5.3

Namespace

Symfony\Component\Validator\Tests\Constraints

Code

protected function setObject($object) {
  $this->object = $object;
  $this->metadata = is_object($object) ? new ClassMetadata(get_class($object)) : null;
  switch ($this
    ->getApiVersion()) {
    case Validation::API_VERSION_2_4:
      $this->context = $this
        ->createContext();
      $this->validator
        ->initialize($this->context);
      break;
    case Validation::API_VERSION_2_5:
    case Validation::API_VERSION_2_5_BC:
      $this->context
        ->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
      break;
  }
}