|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
namespace Symfony\Tests\Component\Validator;
|
|
namespace Symfony\Tests\Component\Validator;
|
|
|
|
|
|
|
|
+use Annotations\Reader;
|
|
use Symfony\Component\Validator\Validator;
|
|
use Symfony\Component\Validator\Validator;
|
|
use Symfony\Component\Validator\ValidatorContext;
|
|
use Symfony\Component\Validator\ValidatorContext;
|
|
use Symfony\Component\Validator\ValidatorFactory;
|
|
use Symfony\Component\Validator\ValidatorFactory;
|
|
@@ -75,14 +76,14 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
public function testBuildDefaultFromAnnotations()
|
|
public function testBuildDefaultFromAnnotations()
|
|
{
|
|
{
|
|
- if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
|
|
|
|
- $this->markTestSkipped('Doctrine is required for this test');
|
|
|
|
|
|
+ if (!class_exists('Annotations\Reader')) {
|
|
|
|
+ $this->markTestSkipped('Annotations is required for this test');
|
|
}
|
|
}
|
|
$factory = ValidatorFactory::buildDefault();
|
|
$factory = ValidatorFactory::buildDefault();
|
|
|
|
|
|
$context = new ValidatorContext();
|
|
$context = new ValidatorContext();
|
|
$context
|
|
$context
|
|
- ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader()))
|
|
|
|
|
|
+ ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(new Reader())))
|
|
->setConstraintValidatorFactory(new ConstraintValidatorFactory());
|
|
->setConstraintValidatorFactory(new ConstraintValidatorFactory());
|
|
|
|
|
|
$this->assertEquals(new ValidatorFactory($context), $factory);
|
|
$this->assertEquals(new ValidatorFactory($context), $factory);
|
|
@@ -90,18 +91,14 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
public function testBuildDefaultFromAnnotationsWithCustomNamespaces()
|
|
public function testBuildDefaultFromAnnotationsWithCustomNamespaces()
|
|
{
|
|
{
|
|
- if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
|
|
|
|
- $this->markTestSkipped('Doctrine is required for this test');
|
|
|
|
|
|
+ if (!class_exists('Annotations\Reader')) {
|
|
|
|
+ $this->markTestSkipped('Annotations is required for this test');
|
|
}
|
|
}
|
|
- $factory = ValidatorFactory::buildDefault(array(), true, array(
|
|
|
|
- 'myns' => 'My\\Namespace\\',
|
|
|
|
- ));
|
|
|
|
|
|
+ $factory = ValidatorFactory::buildDefault(array(), true);
|
|
|
|
|
|
$context = new ValidatorContext();
|
|
$context = new ValidatorContext();
|
|
$context
|
|
$context
|
|
- ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(array(
|
|
|
|
- 'myns' => 'My\\Namespace\\',
|
|
|
|
- ))))
|
|
|
|
|
|
+ ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(new Reader())))
|
|
->setConstraintValidatorFactory(new ConstraintValidatorFactory());
|
|
->setConstraintValidatorFactory(new ConstraintValidatorFactory());
|
|
|
|
|
|
$this->assertEquals(new ValidatorFactory($context), $factory);
|
|
$this->assertEquals(new ValidatorFactory($context), $factory);
|
|
@@ -136,7 +133,7 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
|
|
public function testBuildDefaultFromStaticMethod()
|
|
public function testBuildDefaultFromStaticMethod()
|
|
{
|
|
{
|
|
$path = __DIR__.'/Mapping/Loader/constraint-mapping.yml';
|
|
$path = __DIR__.'/Mapping/Loader/constraint-mapping.yml';
|
|
- $factory = ValidatorFactory::buildDefault(array(), false, null, 'loadMetadata');
|
|
|
|
|
|
+ $factory = ValidatorFactory::buildDefault(array(), false, 'loadMetadata');
|
|
|
|
|
|
$context = new ValidatorContext();
|
|
$context = new ValidatorContext();
|
|
$context
|
|
$context
|
|
@@ -148,17 +145,17 @@ class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
public function testBuildDefaultFromMultipleLoaders()
|
|
public function testBuildDefaultFromMultipleLoaders()
|
|
{
|
|
{
|
|
- if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
|
|
|
|
- $this->markTestSkipped('Doctrine is required for this test');
|
|
|
|
|
|
+ if (!class_exists('Annotations\Reader')) {
|
|
|
|
+ $this->markTestSkipped('Annotations is required for this test');
|
|
}
|
|
}
|
|
$xmlPath = __DIR__.'/Mapping/Loader/constraint-mapping.xml';
|
|
$xmlPath = __DIR__.'/Mapping/Loader/constraint-mapping.xml';
|
|
$yamlPath = __DIR__.'/Mapping/Loader/constraint-mapping.yml';
|
|
$yamlPath = __DIR__.'/Mapping/Loader/constraint-mapping.yml';
|
|
- $factory = ValidatorFactory::buildDefault(array($xmlPath, $yamlPath), true, null, 'loadMetadata');
|
|
|
|
|
|
+ $factory = ValidatorFactory::buildDefault(array($xmlPath, $yamlPath), true, 'loadMetadata');
|
|
|
|
|
|
$chain = new LoaderChain(array(
|
|
$chain = new LoaderChain(array(
|
|
new XmlFilesLoader(array($xmlPath)),
|
|
new XmlFilesLoader(array($xmlPath)),
|
|
new YamlFilesLoader(array($yamlPath)),
|
|
new YamlFilesLoader(array($yamlPath)),
|
|
- new AnnotationLoader(),
|
|
|
|
|
|
+ new AnnotationLoader(new Reader()),
|
|
new StaticMethodLoader('loadMetadata'),
|
|
new StaticMethodLoader('loadMetadata'),
|
|
));
|
|
));
|
|
|
|
|