/**
  * @param Request $request
  * @return $this
  */
 protected function __setRequest(Request $request)
 {
     if (null !== $this->login && !$request->getLogin()) {
         $request->setLogin($this->login);
     }
     if (null !== $this->password && !$request->getPassword()) {
         $request->setPassword($this->password);
     }
     if (($constraints = $this->validatorBuilder->getValidator()->validate($request)) && $constraints->count()) {
         $error = $constraints->get(0);
         throw new ValidatorException($error->getPropertyPath() . ": " . $error->getMessage());
     }
     return $this;
 }
Exemple #2
0
 protected function initFormWithRequest($type, $data, $options)
 {
     $this->validatorBuilder = Validation::createValidatorBuilder();
     $this->formFactoryBuilder = Forms::createFormFactoryBuilder()->addExtension(new HttpFoundationExtension());
     $this->translator = Translator::getInstance();
     $this->validatorBuilder->setTranslationDomain('validators')->setTranslator($this->translator);
 }
 public function testSetApiVersion24And25()
 {
     if (version_compare(PHP_VERSION, '5.3.9', '<')) {
         $this->markTestSkipped('Not supported prior to PHP 5.3.9');
     }
     $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC));
     $this->assertInstanceOf('Symfony\\Component\\Validator\\Validator\\LegacyValidator', $this->builder->getValidator());
 }
 public function testLegacySetApiVersion24And25()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     if (PHP_VERSION_ID < 50309) {
         $this->markTestSkipped('Not supported prior to PHP 5.3.9');
     }
     $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC));
     $this->assertInstanceOf('Symfony\\Component\\Validator\\Validator\\LegacyValidator', $this->builder->getValidator());
 }
Exemple #5
0
 public function __call($method, $args)
 {
     $class = "Aliexpress\\Open\\Method\\" . $method;
     if (!class_exists($class)) {
         throw new NoMethodExists($class);
     }
     $reflect = new \ReflectionClass($class);
     $instance = $reflect->newInstanceArgs($args);
     if (($constraints = $this->validatorBuilder->getValidator()->validate($instance)) && $constraints->count()) {
         $error = $constraints->get(0);
         throw new ValidatorException($error->getPropertyPath() . ": " . $error->getMessage());
     }
     return $instance;
 }
 public function testSetTranslationDomain()
 {
     $this->assertSame($this->builder, $this->builder->setTranslationDomain('TRANS_DOMAIN'));
 }
 public function testSetConstraintValidatorFactory()
 {
     $this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory($this->getMock('Symfony\\Component\\Validator\\ConstraintValidatorFactoryInterface')));
 }
 public function testGetValidator()
 {
     $this->assertInstanceOf('Symfony\\Component\\Validator\\Validator\\RecursiveValidator', $this->builder->getValidator());
 }
Exemple #9
0
 /**
  * Registers validation constraints for the xAPI models on a ValidatorBuilder.
  *
  * @param ValidatorBuilderInterface $builder The ValidatorBuilder
  */
 public static function registerXApiConstraints(ValidatorBuilderInterface $builder)
 {
     $builder->addXmlMappings(array(__DIR__ . '/../metadata/validator/Activity.xml', __DIR__ . '/../metadata/validator/Agent.xml', __DIR__ . '/../metadata/validator/Group.xml', __DIR__ . '/../metadata/validator/Statement.xml'));
 }
 /**
  * @group legacy
  */
 public function testLegacySetApiVersion24And25()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC));
     $this->assertInstanceOf('Symfony\\Component\\Validator\\Validator\\LegacyValidator', $this->builder->getValidator());
 }