This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Validator/ValidatorContextTest.php
stloyd edf4b87dcb Add missing "tearDown" functions, and some missing variable declaration (this saves for me almost 20MB when run all tests)
Force AsseticBundle tests to use TestCase
Fix test for DoctrineBundle to use TestCase
2011-06-16 15:06:36 +02:00

62 lines
1.9 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Tests\Component\Validator;
use Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\ValidatorContext;
class ValidatorContextTest extends \PHPUnit_Framework_TestCase
{
protected $context;
protected function setUp()
{
$this->context = new ValidatorContext();
}
protected function tearDown()
{
$this->context = null;
}
public function testSetClassMetadataFactory()
{
$factory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface');
$result = $this->context->setClassMetadataFactory($factory);
$this->assertSame($this->context, $result);
$this->assertSame($factory, $this->context->getClassMetadataFactory());
}
public function testSetConstraintValidatorFactory()
{
$factory = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface');
$result = $this->context->setConstraintValidatorFactory($factory);
$this->assertSame($this->context, $result);
$this->assertSame($factory, $this->context->getConstraintValidatorFactory());
}
public function testGetValidator()
{
$metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface');
$validatorFactory = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface');
$validator = $this->context
->setClassMetadataFactory($metadataFactory)
->setConstraintValidatorFactory($validatorFactory)
->getValidator();
$this->assertEquals(new Validator($metadataFactory, $validatorFactory), $validator);
}
}