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'); }
/** * @expectedException Symfony\Component\Validator\Exception\MappingException */ public function testBuildDefaultThrowsExceptionIfUnknownExtension() { ValidatorFactory::buildDefault(array(__DIR__ . '/Mapping/Loader/StaticMethodLoaderTest.php')); }
protected function setUp() { $this->validator = ValidatorFactory::buildDefault()->getValidator(); }