예제 #1
0
 public static function create(IContainer $context)
 {
     $loaders = array();
     $context = new ValidatorContext();
     AnnotationRegistry::registerAutoloadNamespaces(array('\\Doctrine\\ORM\\Mapping\\', '\\Symfony\\Component\\Validator\\Constraints\\'));
     $annotationReader = new AnnotationReader();
     $annotationReader->setIgnoreNotImportedAnnotations(true);
     $loader = new AnnotationLoader($annotationReader);
     $context->setClassMetadataFactory(new ClassMetadataFactory($loader));
     $context->setConstraintValidatorFactory(new ConstraintValidatorFactory());
     $factory = new SymfonyValidatorFactory($context);
     return $factory->getValidator();
 }
 protected function setUp()
 {
     parent::setUp();
     $adapters = array('doctrine_orm' => array('manager' => 'Doctrine\\ORM\\EntityManager', 'adapter' => 'Lexik\\Bundle\\FixturesMapperBundle\\Adapter\\DoctrineORMAdapter'));
     $validator = ValidatorFactory::buildDefault(array(), true)->getValidator();
     $this->csvLoader = new CsvLoader($this->getMockSqliteEntityManager(), $adapters, $validator, 'Lexik\\Bundle\\FixturesMapperBundle\\Mapper\\Mapper', '|');
 }
 protected function setUp()
 {
     parent::setUp();
     $adapters = array('doctrine_orm' => array('manager' => 'Doctrine\\ORM\\EntityManager', 'adapter' => 'Lexik\\Bundle\\FixturesMapperBundle\\Adapter\\DoctrineORMAdapter'));
     $this->validator = ValidatorFactory::buildDefault(array(), true)->getValidator();
     $this->csvLoader = new CsvLoader($this->em, $adapters, $this->validator, 'Lexik\\Bundle\\FixturesMapperBundle\\Mapper\\Mapper', '|');
     $this->yamlLoader = new YamlLoader($this->em, $adapters, $this->validator, 'Lexik\\Bundle\\FixturesMapperBundle\\Mapper\\Mapper', '|');
     $this->articleMapper = $this->yamlLoader->load(__DIR__ . '/../Fixture/Yaml/article.yml');
     $this->commentMapper = $this->yamlLoader->load(__DIR__ . '/../Fixture/Yaml/comment.yml');
     $this->categoryMapper = $this->yamlLoader->load(__DIR__ . '/../Fixture/Yaml/category.yml');
 }
예제 #4
0
 /**
  * @expectedException Symfony\Component\Validator\Exception\MappingException
  */
 public function testBuildDefaultThrowsExceptionIfUnknownExtension()
 {
     ValidatorFactory::buildDefault(array(__DIR__ . '/Mapping/Loader/StaticMethodLoaderTest.php'));
 }
예제 #5
0
파일: OfertaTest.php 프로젝트: neozoe/Cupon
 protected function setUp()
 {
     $this->validator = ValidatorFactory::buildDefault()->getValidator();
 }