LegacyValidatorTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Tests;
  11. use Symfony\Component\Translation\IdentityTranslator;
  12. use Symfony\Component\Validator\Constraints\Valid;
  13. use Symfony\Component\Validator\ConstraintValidatorFactory;
  14. use Symfony\Component\Validator\MetadataFactoryInterface;
  15. use Symfony\Component\Validator\Tests\Fixtures\Entity;
  16. use Symfony\Component\Validator\Tests\Validator\AbstractLegacyApiTest;
  17. use Symfony\Component\Validator\Validator as LegacyValidator;
  18. /**
  19. * @group legacy
  20. */
  21. class LegacyValidatorTest extends AbstractLegacyApiTest
  22. {
  23. protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array())
  24. {
  25. $translator = new IdentityTranslator();
  26. $translator->setLocale('en');
  27. return new LegacyValidator($metadataFactory, new ConstraintValidatorFactory(), $translator, 'validators', $objectInitializers);
  28. }
  29. /**
  30. * @expectedException \Symfony\Component\Validator\Exception\ValidatorException
  31. */
  32. public function testValidateValueRejectsValid()
  33. {
  34. $this->validator->validateValue(new Entity(), new Valid());
  35. }
  36. }