From 1ff081d93f761e2444d31f9eceb05f69fd93ed08 Mon Sep 17 00:00:00 2001 From: Andreas Hucks Date: Sat, 25 Aug 2012 17:59:01 +0200 Subject: [PATCH] added tests for ValidatorBuilder fluent interface --- .../Validator/Tests/ValidatorBuilderTest.php | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php new file mode 100644 index 0000000000..d963e4a848 --- /dev/null +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -0,0 +1,110 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests; + +use Symfony\Component\Validator\ValidatorBuilder; +use Symfony\Component\Validator\ValidatorBuilderInterface; + +class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ValidatorBuilderInterface + */ + protected $builder; + + protected function setUp() + { + $this->builder = new ValidatorBuilder(); + } + + protected function tearDown() + { + $this->builder = null; + } + + public function testAddObjectInitializer() + { + $this->assertSame($this->builder, $this->builder->addObjectInitializer( + $this->getMock('Symfony\Component\Validator\ObjectInitializerInterface') + )); + } + + public function testAddObjectInitializers() + { + $this->assertSame($this->builder, $this->builder->addObjectInitializers(array())); + } + + public function testAddXmlMapping() + { + $this->assertSame($this->builder, $this->builder->addXmlMapping('mapping')); + } + + public function testAddXmlMappings() + { + $this->assertSame($this->builder, $this->builder->addXmlMappings(array())); + } + + public function testAddYamlMapping() + { + $this->assertSame($this->builder, $this->builder->addYamlMapping('mapping')); + } + + public function testAddYamlMappings() + { + $this->assertSame($this->builder, $this->builder->addYamlMappings(array())); + } + + public function testAddMethodMapping() + { + $this->assertSame($this->builder, $this->builder->addMethodMapping('mapping')); + } + + public function testAddMethodMappings() + { + $this->assertSame($this->builder, $this->builder->addMethodMappings(array())); + } + + public function testEnableAnnotationMapping() + { + if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) { + $this->markTestSkipped('Annotations is required for this test'); + } + + $this->assertSame($this->builder, $this->builder->enableAnnotationMapping()); + } + + public function testDisableAnnotationMapping() + { + $this->assertSame($this->builder, $this->builder->disableAnnotationMapping()); + } + + public function testSetMetadataFactory() + { + $this->assertSame($this->builder, $this->builder->setMetadataFactory( + $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface')) + ); + } + + public function testSetMetadataCache() + { + $this->assertSame($this->builder, $this->builder->setMetadataCache($this->getMock( + 'Symfony\Component\Validator\Mapping\Cache\CacheInterface')) + ); + } + + public function testSetConstraintValidatorFactory() + { + $this->assertSame($this->builder, $this->builder->setConstraintValidatorFactory( + $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface')) + ); + } +}