4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Tests;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Validator\ValidatorBuilder;
16 use Symfony\Component\Validator\ValidatorBuilderInterface;
18 class ValidatorBuilderTest extends TestCase
21 * @var ValidatorBuilderInterface
25 protected function setUp()
27 $this->builder = new ValidatorBuilder();
30 protected function tearDown()
32 $this->builder = null;
35 public function testAddObjectInitializer()
37 $this->assertSame($this->builder, $this->builder->addObjectInitializer(
38 $this->getMockBuilder('Symfony\Component\Validator\ObjectInitializerInterface')->getMock()
42 public function testAddObjectInitializers()
44 $this->assertSame($this->builder, $this->builder->addObjectInitializers(array()));
47 public function testAddXmlMapping()
49 $this->assertSame($this->builder, $this->builder->addXmlMapping('mapping'));
52 public function testAddXmlMappings()
54 $this->assertSame($this->builder, $this->builder->addXmlMappings(array()));
57 public function testAddYamlMapping()
59 $this->assertSame($this->builder, $this->builder->addYamlMapping('mapping'));
62 public function testAddYamlMappings()
64 $this->assertSame($this->builder, $this->builder->addYamlMappings(array()));
67 public function testAddMethodMapping()
69 $this->assertSame($this->builder, $this->builder->addMethodMapping('mapping'));
72 public function testAddMethodMappings()
74 $this->assertSame($this->builder, $this->builder->addMethodMappings(array()));
77 public function testEnableAnnotationMapping()
79 $this->assertSame($this->builder, $this->builder->enableAnnotationMapping());
82 public function testDisableAnnotationMapping()
84 $this->assertSame($this->builder, $this->builder->disableAnnotationMapping());
87 public function testSetMetadataCache()
89 $this->assertSame($this->builder, $this->builder->setMetadataCache(
90 $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock())
94 public function testSetConstraintValidatorFactory()
96 $this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory(
97 $this->getMockBuilder('Symfony\Component\Validator\ConstraintValidatorFactoryInterface')->getMock())
101 public function testSetTranslator()
103 $this->assertSame($this->builder, $this->builder->setTranslator(
104 $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock())
108 public function testSetTranslationDomain()
110 $this->assertSame($this->builder, $this->builder->setTranslationDomain('TRANS_DOMAIN'));
113 public function testGetValidator()
115 $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator());